...

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



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

Thanks!

Eric

circusbred
10-06-2004, 07: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.

Dalsor
10-06-2004, 08: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.

circusbred
10-06-2004, 08: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!

Dalsor
10-06-2004, 11:39 PM
Hmmm. Good idea. Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum