views:

619

answers:

2

I have buy.php with a form where you enter items, quantity, shipping data, etc. When you click the Submit button, it posts back to buy.php ($_SERVER['PHP_SELF']) and does some data validation. If there are fields missing or errors, they are highlighted. If everything is correct, I save the $_POST data in $_SESSION variables, then do a header('Location: check.php'), where I display the data so the buyer can check the info one last time before actually buying.

Now, if I'm in check.php and hit the Back button to buy.php so I can change stuff, the browser asks if I want to resend the POST data. I'm trying to avoid that. Anyone have any good advice or good practices for PHP Multiform validation? Also, if I had n pages for the user to fill, buy.php, buy2.php ... buyn.php before check.php would the same ideas still hold?

Thanks for the help!

+2  A: 

You could do a redirect to buy.php after saving to the session object, which then does a server redirect to check.php, it would mean when the user clicks back, they're going back to the GET request not the POST request

Glenn Slaven
A: 

Yes, thanks for your answer. Seems to be what I was trying to do. Just replicated this behavior on a minor scale (very simple test pages) and it works. Need to figure out what I'm doing wrong in the real project.

Mariano