fugix Posted May 7, 2011 Share Posted May 7, 2011 hey guys, im trying to figure out how to fix the issue of after a form is submitted, when i click refresh, and the form is submitted again, i know why it does it but im not sure how to remedy it...any thoughts? Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/ Share on other sites More sharing options...
efficacious Posted May 7, 2011 Share Posted May 7, 2011 you could try setting a session variable to flag that the form has been submitted once and then when the page is refreshed you can use php to hide the form or w/e if(isset($_SESSION['FormSent'])) { //No Form } else { //Form } ? maybe? Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1211790 Share on other sites More sharing options...
fugix Posted May 7, 2011 Author Share Posted May 7, 2011 i need the form to always be there though Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1211807 Share on other sites More sharing options...
efficacious Posted May 7, 2011 Share Posted May 7, 2011 you could do a redirect after the sumbmission so that its already past the point of return.. just carry the result data with you to the next page.. that way if the user refreshes.. nothing (on that page) would have been submitted so the submission will never have to be repeated Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1211808 Share on other sites More sharing options...
fugix Posted May 7, 2011 Author Share Posted May 7, 2011 hmmm, il try that Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1211812 Share on other sites More sharing options...
ignace Posted May 7, 2011 Share Posted May 7, 2011 Submit your POST data to different/same page, process it, then redirect them to wherever it is you want them to go. http://en.wikipedia.org/wiki/Post/Redirect/Get if($_SERVER['REQUEST_METHOD'] == 'POST') { // do stuff with $_POST // change from POST to GET header('Location: ' . $_SERVER['SCRIPT_NAME']); exit(0); } // form Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1211838 Share on other sites More sharing options...
efficacious Posted May 7, 2011 Share Posted May 7, 2011 i said that already but the posted resource is nice Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1211839 Share on other sites More sharing options...
spiderwell Posted May 7, 2011 Share Posted May 7, 2011 this came up the other day on here, post by double dee i think. all the suggestions above were stated in that post too. I think the session idea is best, combined with the redirect to really lock it down. wonder if you can remove/reset browser history in javascript, and prevent back being pressed, hehe now that would be cool Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1211873 Share on other sites More sharing options...
fugix Posted May 7, 2011 Author Share Posted May 7, 2011 yeah, its more of a big deal in chrome than any other browser...quite annoying Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1211973 Share on other sites More sharing options...
ignace Posted May 7, 2011 Share Posted May 7, 2011 It's in every browser. It's not specific to one browser. Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1211990 Share on other sites More sharing options...
fugix Posted May 7, 2011 Author Share Posted May 7, 2011 thank you for the resource....very helpful Link to comment https://forums.phpfreaks.com/topic/235747-how-to-fix-refresh-resubmitting-of-form/#findComment-1212003 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.