Issue with resubmitting form data
1 answer
You probably want to implement the Post-Redirect-Get method .
Since you made a post and you didn't redirect, the POST data may be sent again due to browser behavior. You have to redirect after POST to stop this.
The diagram below shows the PRG flow:
alt text http://upload.wikimedia.org/wikipedia/en/3/3c/PostRedirectGet_DoubleSubmitSolution.png
To do this, on your publish page, instead of displaying results, you redirect the user to a different results page.
eg.
function redirect($url){
header('Location: '.$url);
exit;
}
if(isset($_POST['submit'])){
$ok = checkLogin($username,$password);
if($ok){
redirect('thank-you.php');
}else{
redirect('login.php?error');
}
}
+3
source to share