Jump to content

Preventing resubmition of a form when clicking the back button


play_

Recommended Posts

Can it be done?

If my title isn't too clear, what i mean is, in some sites, you fill a form and when you click submit, you're taken to another page.
If you click the browser's back button, a popup message will warn you that the information will be resubmitted.

How do i prevent that from popping up?
Thanks pocobueno.
Didn't quite work though (at least with the refresh button).

[code]<?php
header("Cache-control: private");
?>
<form action="#" method="post">
<input type="text" name="name" />
<input type="submit" name="submit" />
</form>
<?php
if (isset($_POST['submit'])) {
echo $_POST['name'];
}
?>[/code]

If i submit it, and refresh the page, FF throws a pop up at me saying the $_POST data will be resent.
But i am testing it just on one page. I run that script on one page. Shouldn't it work there?


but ok, let me try on the real site


::edit::
Nope, didn't work.
I have "header.php" which is included in every page on the site. put it there and didn't work.
http://www.boutell.com/newfaq/creating/stoprefresh.html
try reading it, it is not suggested to do if unless you are doing some shopping site which you dont want your customer to pay twice, but other situactions like sending email or others which are not that serious, preventing the refresh by redirection should be enough...
Ted

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.