NoSalt Posted November 30, 2007 Share Posted November 30, 2007 Hello All I have a question about form handling with PHP. Let's say I have a page named "questionnaire.php" and on that page I have a form. The form tag looks something like this: <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Some one submits the form and if it is successful, they go to another page, say "thankYou.php". Now here is my question. If that person hits the "Back" button in their browser (to go from thankYou.php back to questionnaire.php) they get the standard "you are trying to resubmit the form" warning. Is there any way to avoid this happening? Is there a way to not have the form try to re-submit when you hit the "Back" button? Thanks everybody for reading Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 30, 2007 Share Posted November 30, 2007 use header file to redirect the user and remove the post data header('location: yourpage.php'); Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted November 30, 2007 Share Posted November 30, 2007 http://www.phpfreaks.com/forums/index.php/topic,166322.0.html PhREEEk Quote Link to comment Share on other sites More sharing options...
NoSalt Posted November 30, 2007 Author Share Posted November 30, 2007 use header file to redirect the user and remove the post data header('location: yourpage.php'); Interesting idea ... but how would you go about implementing this??? Thanks Quote Link to comment Share on other sites More sharing options...
NoSalt Posted December 1, 2007 Author Share Posted December 1, 2007 Any takers??? I would really appreciate any help anybody can give. Thanks Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted December 1, 2007 Share Posted December 1, 2007 Either after the php file has processed the information, or on the thankyou.php page. Thats where i would do it Quote Link to comment Share on other sites More sharing options...
mlin Posted December 1, 2007 Share Posted December 1, 2007 header(); needs to be sent to the browser before any other output. I'm not sure it would help anything, but it's worth a shot. also, just a quick thing. the action attribute in your form tag could be empty and produce the same results. action will default to the current file so you really don't have to open php and echo PHP_SELF Quote Link to comment 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.