SkarrQ Posted July 20, 2015 Share Posted July 20, 2015 Hi people, i really need help with my PHP code. I have no idea how to do validation on my Form... you know, to make sure that user is editing correct information. I really need help with this one please!!! This is how my Form code: <?php require 'Controller/BikeController.php'; $BikeController = new BikeController(); $title = "Add a new Bike"; /******************************************************* Thiese are all the field for Add a new Bike page for editing *******************************************************/ $content ="<form action='' method='post'> <fieldset> <legend>Add a new Bike</legend> <label for='name'>Name: </label> <input type='text' class='inputField' name='txtName' /><br/> <label for='type'>Type: </label> <select class='inputField' name='ddlType'> <option value='%'>All</option>" .$BikeController->CreateOptionValues($BikeController->GetBikeTypes()). "</select><br/> <label for='price'>Price: </label> <input type='text' class='inputField' name='txtPrice' /><br/> <label for='roast'>Code: </label> <input type='text' class='inputField' name='txtCode' /><br/> <label for='discount'>Discount: </label> <input type='text' class='inputField' name='txtDiscount' /><br/> <label for='image'>Image: </label> <select class='inputField' name='ddlImage'>" .$BikeController->GetImages(). "</select></br> </select></br> <label for='review'>Review: </label> <textarea cols='70' rows='12' name='txtReview'></textarea></br> <input type='submit' value='Submit'> </fieldset> </form>"; /******************************************************* Calls function InsertBike() *******************************************************/ if(isset($_POST["txtName"])) { //$BikeController->InsertBike(); } include './Templet.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/297374-need-help-with-php-validation-on-my-form/ Share on other sites More sharing options...
ginerjm Posted July 20, 2015 Share Posted July 20, 2015 Have you written any php code? That's what we are here to help with, and since you haven't shown us any php code there's nothing for us to help you with. Quote Link to comment https://forums.phpfreaks.com/topic/297374-need-help-with-php-validation-on-my-form/#findComment-1516838 Share on other sites More sharing options...
SkarrQ Posted July 20, 2015 Author Share Posted July 20, 2015 Have you written any php code? That's what we are here to help with, and since you haven't shown us any php code there's nothing for us to help you with. This is actually a PHP code !!!! If its not, I'm confused. Quote Link to comment https://forums.phpfreaks.com/topic/297374-need-help-with-php-validation-on-my-form/#findComment-1516843 Share on other sites More sharing options...
SkarrQ Posted July 20, 2015 Author Share Posted July 20, 2015 <?php require 'Controller/BikeController.php'; $BikeController = new BikeController(); $title = "Add a new Bike"; /******************************************************* Thiese are all the field for Add a new Bike page for editing *******************************************************/ $content ="<form action='' method='post'> <fieldset> <legend>Add a new Bike</legend> <label for='name'>Name: </label> <input type='text' class='inputField' name='txtName' /><br/> <label for='type'>Type: </label> <select class='inputField' name='ddlType'> <option value='%'>All</option>" .$BikeController->CreateOptionValues($BikeController->GetBikeTypes()). "</select><br/> <label for='price'>Price: </label> <input type='text' class='inputField' name='txtPrice' /><br/> <label for='roast'>Code: </label> <input type='text' class='inputField' name='txtCode' /><br/> <label for='discount'>Discount: </label> <input type='text' class='inputField' name='txtDiscount' /><br/> <label for='image'>Image: </label> <select class='inputField' name='ddlImage'>" .$BikeController->GetImages(). "</select></br> </select></br> <label for='review'>Review: </label> <textarea cols='70' rows='12' name='txtReview'></textarea></br> <input type='submit' value='Submit'> </fieldset> </form>"; /******************************************************* Calls function InsertBike() *******************************************************/ if(isset($_POST["txtName"])) { //$BikeController->InsertBike(); } include './Templet.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/297374-need-help-with-php-validation-on-my-form/#findComment-1516844 Share on other sites More sharing options...
ginerjm Posted July 20, 2015 Share Posted July 20, 2015 The only php logic/code you are showing us is the part that checks for the existence of the 'txtName' field in your html input. Sure you are using a php echo command to store all the html code but I don't see a script that uses that variable (to output it to the client) nor do I see any code that even attempts to receive the input from your form and try to validate it. How about making a stab at receiving the POST data and doing some reading and attempt to write proper handling code? Then ask for help making it correct. Quote Link to comment https://forums.phpfreaks.com/topic/297374-need-help-with-php-validation-on-my-form/#findComment-1516845 Share on other sites More sharing options...
cyberRobot Posted July 20, 2015 Share Posted July 20, 2015 (edited) As ginerjm mentioned, the PHP code shown is used to display the form. Do you have any code that processes the form submission? Basically, it would help to know where you're stuck? Which field(s) are you looking to validate? And what is considered valid? If you're looking for help on the basics of form validation and/or processing form submissions, there are many resources online: https://www.google.com/#q=php+form+validation Edited July 20, 2015 by cyberRobot Quote Link to comment https://forums.phpfreaks.com/topic/297374-need-help-with-php-validation-on-my-form/#findComment-1516862 Share on other sites More sharing options...
SkarrQ Posted July 20, 2015 Author Share Posted July 20, 2015 (edited) ok i will try Edited July 20, 2015 by SkarrQ Quote Link to comment https://forums.phpfreaks.com/topic/297374-need-help-with-php-validation-on-my-form/#findComment-1516863 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.