Jump to content

PHP Form Question


NoSalt

Recommended Posts

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  :)

Link to comment
https://forums.phpfreaks.com/topic/79508-php-form-question/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/79508-php-form-question/#findComment-403789
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.