View Full Version : Reposting Form Data (Hitting Back on Browser)

10-06-2004, 07:19 PM
Anyone have a way to repost form data after hitting the browser back button without the user having to hit retry?



10-06-2004, 08:24 PM
I would think that would depend on the User Agent. You want the form to be reposted after hitting back? Usually that causes a box to popup saying POST session expired, do you want to resend? Or something of the sort.

Are you trying to fill in the form fields with data that was already entered if part of it failed validation? If so, there are better ways to accomplish this than by using the back button, or javascript to emulate the back button.

10-06-2004, 09:00 PM
Exactly. I use a combination of Javascript and PHP to do the form validation and processing. Its rare for this to happen, but when it does it causes grief. When one of my techs hits the back button then hits 'Retry', it wipes out what they had entered. This is for a call tracking app that I've written and sometimes the techs have entered a lot of information -- which gets gone.

10-06-2004, 09:12 PM
So the problem is with php validation then? Well then:

Sticky forms!

Include the form with include();
put value="<?php echo $_POST['fieldname']; ?>"

If you include the form again when validation fails, and have value="<?php echo $_POST['fieldname']; ?>" in their respective places, all the data will still be there.

This also gives you the oppurtunity to post in red what did not validate, on top of the form, or put a pretty red asterisk next to the culprit.

Edit: Best part: They won't have to hit the back button any longer!

10-07-2004, 12:39 AM
Hmmm. Good idea. Thanks!