View Full Version : User entered data disappears on goback

09-21-2006, 01:26 AM
I have a simple HTML form for my visitors to fill out some input fields. This information gets validated by a php function that either 1. accepts the data and emails it to me OR 2. tells the client that there is something wrong with his data entry that he needs to correct (one or more obligatory fields missing; no @ in the email name; etc.) and sends the client back like this

echo "<FORM method=\"POST\" name=\"GoBack\">\n";
echo "<p style=\"style5\">Please enter a valid email address.<\p>\n";
echo "<p><INPUT TYPE=\"button\" NAME=\"GoBack\" VALUE=\"Back\" OnClick=\"javascript:window.history.back(1)\">\n";
echo "</FORM>\n";

but the data that the client has entered disappears.
My question: How do I make sure (as much as possible) that the client does not have to re-enter all the fields again?

Thank you for anyone who can help me on this issue!

09-21-2006, 07:43 AM
after validation you just put the variables in the value field of the form before sending the html. So in your example that should be easy.


if you initialise the form variables to "" on a GET and always do as above, then there is no difference to code between a get and a post except deciding whether its a get or a post and performing the relevant code before formatting the form output.