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? Quote 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? Quote 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 Quote 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 Quote 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 Quote 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 Quote 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 Quote 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 Quote 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 Quote 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. Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.