Page 1 of 1

Clear $_POST after processed

Posted: Wed Sep 27, 2006 11:17 am
by Skara
My problem is when I hit the back button, I get the 'you have to resubmit the post data' message box.

Can I make it so that if I hit the back button, $_POST won't be resubmitted?

e.g.
page a: fill out form -> submit
page b: back button
(popup): resubmit blah blah blah
page a: $_POST is resubmitted again

Posted: Wed Sep 27, 2006 11:22 am
by d3ad1ysp0rk
What you need is an intermediate page to process the data and another to display the results.

form.html includes a form that posts data to
process.php which does data validation and inserts/selects/whatever from a db then does a header("Location: "); call to
done.php which displays information on what was done or what not.

When they get to done.php and hit back, it will bring them to form.html, since they were really never at process.php (since they were redirected before anything was displayed).

Posted: Thu Sep 28, 2006 2:49 am
by Rovas
That' s a good ideea d3ad1ysp0rk. Also put in your page with the HTML form this code to stop the browser from caching data inputed. You could also try using GET for the second page then you won' t need the third page (done.php) that d3ad1ysp0rk suggested but only if you trust the validation done in the first page.

Code: Select all

header( "Cache-Control: no-cache, must-revalidate" );
	    header( "Pragma: no-cache" );

Posted: Mon Oct 02, 2006 4:28 pm
by Skara
Ah, ok. I was thinking that header(Location:) would still log a back button. Silly me, that would be impossible since the browser never got it. ^^;

Thanks!