play_ Posted January 18, 2007 Share Posted January 18, 2007 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? Link to comment https://forums.phpfreaks.com/topic/34710-preventing-resubmition-of-a-form-when-clicking-the-back-button/ Share on other sites More sharing options...
pocobueno1388 Posted January 18, 2007 Share Posted January 18, 2007 Put this at the top of your header page:[code]header("Cache-control: private");[/code] Link to comment https://forums.phpfreaks.com/topic/34710-preventing-resubmition-of-a-form-when-clicking-the-back-button/#findComment-163581 Share on other sites More sharing options...
play_ Posted January 18, 2007 Author Share Posted January 18, 2007 Thanks pocobueno.Didn't quite work though (at least with the refresh button).[code]<?phpheader("Cache-control: private");?><form action="#" method="post"><input type="text" name="name" /><input type="submit" name="submit" /></form><?phpif (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. Link to comment https://forums.phpfreaks.com/topic/34710-preventing-resubmition-of-a-form-when-clicking-the-back-button/#findComment-163586 Share on other sites More sharing options...
pocobueno1388 Posted January 18, 2007 Share Posted January 18, 2007 It needs to be on every page that involves that script...if you have a main header page that you include in all your files you should put it in there...it works for me. Link to comment https://forums.phpfreaks.com/topic/34710-preventing-resubmition-of-a-form-when-clicking-the-back-button/#findComment-163587 Share on other sites More sharing options...
play_ Posted January 18, 2007 Author Share Posted January 18, 2007 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. Link to comment https://forums.phpfreaks.com/topic/34710-preventing-resubmition-of-a-form-when-clicking-the-back-button/#findComment-163588 Share on other sites More sharing options...
ted_chou12 Posted January 18, 2007 Share Posted January 18, 2007 http://www.boutell.com/newfaq/creating/stoprefresh.htmltry 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 Link to comment https://forums.phpfreaks.com/topic/34710-preventing-resubmition-of-a-form-when-clicking-the-back-button/#findComment-163723 Share on other sites More sharing options...
play_ Posted January 19, 2007 Author Share Posted January 19, 2007 nice find.thank you ted. Link to comment https://forums.phpfreaks.com/topic/34710-preventing-resubmition-of-a-form-when-clicking-the-back-button/#findComment-164146 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.