zoom123 — 2007-06-23T09:19:23-04:00 — #1
What are some ways to stop a form from being re-submitted if the user reloads the browser?
spikez — 2007-06-23T09:21:25-04:00 — #2
after you have done the processing of the form, redirect the user away to another page using header("Location: next_page.php");
// do form processing
exit(); // stop the script continuing just in case
zoom123 — 2007-06-23T10:03:07-04:00 — #3
Thanks. But I am afraid that would create a "headers send" error in my case and I would have to change several things in order to avoid that.
Any other solutions?
ivanfx — 2007-06-23T10:08:58-04:00 — #4
Use a meta refresh,
echo "<meta http-equiv=\"refresh\" content=\"TIME_HERE;url=URL_HERE\">";
spikez — 2007-06-23T10:34:36-04:00 — #5
Not always, if you add ob_start(); to the top of your script it will stop the errors
thereddevil — 2007-06-23T10:49:04-04:00 — #6
You can also just add a session variable when the form has been submitted successfully. Then on the same time check if the session variable is set before you resubmit the form.
Then it would not matter if the same post data is resubmit, since the session variable would be set.