PHP prevents forms from being submitted repeatedly
Due to the network reason, often came out to point the Submit button, the Web page did not respond, and then click again. This will result in the background received two submissions, so that two times processing, this article to introduce you to prevent the form of repeated submission of several methods
1. Front End Solution
Method One:
Can be solved by the front end. When the user points to the submit button, the first use of JS for effective judgment, no problem, the submit button "disabled" off. and then submit!
Method Two:
Use Ajax to submit the form. When the Submit button is clicked, disable the push button, or set a status value of 1 to indicate that it is being committed. When the submission is made, the judgment is not processed if it is being submitted. Wait until the Ajax returns, and then restore the status.
2. Back-end Solution
Sometimes the front end can not completely solve the problem, such as I used jquery.validateengine, there is no way to set the state. So consider the back end solution.
if (Session ("Act_last_time")!= ') {
if (floor (Time ()-(int) session ("Act_last_time")% 86400/60) <1) {
$ This->error ("Sorry, not frequent submissions within a minute!") ", U (' Wap/myact/list '), 5);
}
} else{
$t = (int) time ();
echo $t;
$_session ("Act_last_time", $t);
}
The back end solution is not very friendly, but absolutely effective. That is, the submission frequency is controlled. I set it here for 1 minutes.
Thank you for reading, I hope to help you, thank you for your support for this site!