In Yahoo or Google and in many websites when you fill up a form and if your form has any errors it gets redirected to the same page. Note that the data in the form remains as it is. I mean the data in the text fields remains the same. I tried ‹form action='(same page here)’ method=’post or get’›. It gets redirected to the page, but the contents of the form gets cleared. I want the data to be displayed.
You know how tiresome it will be for the user if he has to fill up the entire form once again if he just forgets to check the accept terms and conditions checkbox. Need help!
Here is a modified version of what I use for very simple websites where I don’t want/need an entire framework to get the job done.
(I have a few similar functions for
<select> and<textarea>and so on)When you’re building fields you can do something like:
If you process your forms in the same page as the form itself, they will get auto filled if there are any errors. Most frameworks, though, do all of this for you (and in a much better way than the code above), I personally suggest
CakePHPorCodeIgniter.