Jump to content

how to fix "refresh= resubmitting of form"


fugix

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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.