phpknight Posted October 22, 2007 Share Posted October 22, 2007 I have a site that is form intensive and would like to prevent users on my site from resubmitting forms when they press back or forward, which they will likely do at some point no matter how I program it. So, I am interested from hearing from people who 1) had the same need and 2) implemented something in PHP with which they were satisfied. How did you go about doing this? Please do not respond unless you have actually done this in practice and not theory. Quote Link to comment https://forums.phpfreaks.com/topic/74278-solved-preventing-backforward-button-form-resubmission/ Share on other sites More sharing options...
JJohnsenDK Posted October 22, 2007 Share Posted October 22, 2007 use a seperate script where you do the submitting... you have the form in one page and then you action it to anohter page, which do the database update, or what ever you want to do, then you redirect to the last page. Very nice and simpel solution... the way i am doing it, anyways Quote Link to comment https://forums.phpfreaks.com/topic/74278-solved-preventing-backforward-button-form-resubmission/#findComment-375280 Share on other sites More sharing options...
corillo181 Posted October 22, 2007 Share Posted October 22, 2007 you can't not prevent the user from pressing back; one thing that can be done is putting the script in a different page with a redirect; that way if they press back they will only go back to the form and not the script. Quote Link to comment https://forums.phpfreaks.com/topic/74278-solved-preventing-backforward-button-form-resubmission/#findComment-375281 Share on other sites More sharing options...
phpknight Posted October 22, 2007 Author Share Posted October 22, 2007 Hmm. Looks like I might be stuck. I generally like to just redisplay the same form with the information + error messages and let them resubmit to get it right. Could I have something just as user friendly but also implement the redirect? Quote Link to comment https://forums.phpfreaks.com/topic/74278-solved-preventing-backforward-button-form-resubmission/#findComment-375286 Share on other sites More sharing options...
JJohnsenDK Posted October 22, 2007 Share Posted October 22, 2007 use sessions if you want the data the user put in, to be saved after you have run the validate script... ######## formscript.php action="validate.php" ######## ######## validate.php validate information if not validated -> set sessions redirect to formscript.php ######## ######## formscript.php use the session information if the session are set. (If the sessions are set this would mean that the data was not validated). Quote Link to comment https://forums.phpfreaks.com/topic/74278-solved-preventing-backforward-button-form-resubmission/#findComment-375302 Share on other sites More sharing options...
phpknight Posted October 22, 2007 Author Share Posted October 22, 2007 Okay, I'll think about it. It would take a lot of reworking because now I use sessions to set validated variables! Quote Link to comment https://forums.phpfreaks.com/topic/74278-solved-preventing-backforward-button-form-resubmission/#findComment-375306 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.