This article mainly introduces a simple example of PHP to prevent repeated data submission by post, using session to record a value, if you need a friend, you can refer to this question during an interview with an empire: how to handle the repeated post submission problem, and then talk with @ Warm Yang. He said that I didn't understand the record time, what I want is to use the session to record the form page and then submit the page for judgment. If it is equal, it is regarded as successful and the session is cleared. But the problem is that if the form page is html, what should I do? Do you want to call a php verification page? Similar to the Verification Code function. It is also said to set the expiration time using the header... but did not try. The following is written in php and is available after testing.
The Code is as follows:
// Enable session
Session_start ();
// If a submission ID exists
If (isset ($ _ GET ['action']) & $ _ GET ['action'] = 'save '){
// If a session exists and it is the same as the passed value, it is submitted.
If (isset ($ _ SESSION ['_ open_auth']) & isset ($ _ POST ['auth']) & $ _ SESSION ['_ open_auth'] =$ _ POST ['auth ']) {
Print_r ($ _ POST );
$ _ SESSION ['_ open_auth'] = null; // clear
} Else {
// Start
Header ("location: post. php ");
}
Exit ();
}
// Authorization
$ Auth = $ _ SESSION ['_ open_auth'] = time ();
?>
Post