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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.