Link to home
Start Free TrialLog in
Avatar of x_terminat_or_3
x_terminat_or_3

asked on

Clear POST data

Hi

How can I clear the POST data after processing them?  So that when the users press the REFRESH button, the data isn't resend?



Ramses (x_terminat_or_3)
SOLUTION
Avatar of alexmay
alexmay

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of x_terminat_or_3
x_terminat_or_3

ASKER

It isn't...
To clear post data:

$_POST = array();

but that will not prevent the behaviour you are seeing of the browser trying to resend the data,

You need to point the form to a seperate page (eg. <form action="process.php.... ) then in that file you would have

<?php
//process form data
header("location: destination_page.php");
exit;
?>

where destination_page.php is the page the user will be redirected to once the data has been processed. This will be invisible to the user, it will appear they have been sent straight to the destination page without the middle man page being present and will prevent the browser tring to resend the data on refresh or hitting the back button.
Yeah but that means that the destination page has to be static

I already saw sites implementing a way that clears POST data but keeps them somehow in memory
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think I like this better ;)
:)

If you have any problems with it feel free to post back.