View Full Version : Set a "back link" to form without clearing the inp
Alex
December 28th, 2004, 14:39
What would be a good way of showing a back link to a page with forms, but keeping the form values?
For example:
user fills in the form, submits, but lets say one input was empty so the PHP script shows an error page, I want to show a back link on that page so the user goes back to complete the form without finding that it's all gone.
What's the best way of doing this?
sonicgroup
December 28th, 2004, 16:40
Well, I would suggest first that you not use a separate, or next, page to do the processing and error reporting. Try to incorporate that into the page with the form. Seeing the error message next to the field with the problem is more helpful than seeing it on a separate page without the form, and then having to go back to correct it.
However, if you really want to do this, the easiest way would be to use sessions to store the POSTed data when the form is submitted. As long as the user doesn't close their browser, the data will be in the session variables for use.
Anoop
December 28th, 2004, 19:01
I'll also suggest to display the error on the same page. It is more user friendly.
You can also display the error message on top of each form field which is a more desirable way to show errors. For this, you can use a <div> element to display the error message if the error message for that particular field is set.
For example, you can write something like this ,
<tr> <td>
<?
if (error['username']) { ?>
<div style="color:red"><? echo error['username']; ?> </div>
<? } ?>
<input name="username" type="text">
</td> </tr>
-Anoop
Alex
December 29th, 2004, 01:32
Thanks, I'll do it right away :)
vBulletin® v3.6.8, Copyright ©2000-2010, Jelsoft Enterprises Ltd.