Jump to content

how to fix "refresh= resubmitting of form"


fugix

Recommended Posts

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?

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

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

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

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.