problem with resubmission of form data
I am a newbie trying to develop some login panel. The problem now is that
I am not able to stop resubmission of form data on pressing back and forward button of browser. Tried to find it on googl开发者_Python百科e but no effective solution come up.
Please enlighten me on this.
You probably want to implement the Post-Redirect-Get method.
Because you did a post and you did not redirect, the POST data might send again due to browser behaviour. You need to redirect after POST in order to stop this.
The diagram below shows the flow of PRG:
alt text http://upload.wikimedia.org/wikipedia/en/3/3c/PostRedirectGet_DoubleSubmitSolution.png
To do this, in your page to post, instead of displaying the results, you redirect the user to another result page.
e.g.
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');
}
}
精彩评论