I have implemented a html form with some fields like email and phone and I want to validate the data before submitting the form. I want to validate the data in the server side (because javascript can be easily avoided) and so I have write some PHP functions. Currently the form is in a Form.html file and the validation script is in a Validate.php file.
If I the validation of the data return false how can I return to my form WITHOUT the fields to be erased?
Considering its PHP and server side you are going to have to validate after a submission no matter what (unless you want to use JS)
If you want to keep the values than you just store them in a seperate variable and echo that out in the html, (Requires the form to be a php file not an html file)
here is an example of me echoing a variable to an html field (not tested), it should basically just convert numbers to letters and echo them to the same field after submission.
Thats my archaic way of doing it, although im sure the experts have a super sleek quick way of doing it rather than an ugly php tag in the middle of your php.
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
Not really archaic; you have to force the submitted values to become the values of the elements somehow. You could always use AJAX and have JavaScript use the .value to alter the element, but that's just more code for equal work.
One last thing. In my form I have some <select> elements with many many options. In order to make the <select> fields to have the values before submission I have to put a small code snippet like this below in each option?
One last thing. In my form I have some <select> elements with many many options. In order to make the <select> fields to have the values before submission I have to put a small code snippet like this below in each option?
Not sure if that would actually work considering your using $_POST's
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
Not sure if that would actually work considering your using $_POST's
I got your point, but I think that the function should have two parameters, one for the value that was selected before submission and one for the value of each option that we run the function, right?
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
Bookmarks