The principle is
If the data passes the preceding two verifications, the data is valid and valid. At this time, we concatenate the submitted data into a string and use MD5 encryption to obtain an MD5 value. Then we put this value on the client through cookies, when the user submits the form next time, we repeat this step and read the MD5 value in the Cookie for comparison, if they are the same, we can conclude that the two submitted forms are the same. Otherwise, this Cookie will be replaced!
| The code is as follows: |
Copy code |
<? Php
//......
$ Lasthash = $ HTTP_COOKIE_VARS ["lasthash"]; // read the last set Cookie value
If (count ($ HTTP_POST_VARS )){
$ Long = "";
While (list ($ key, $ value) = each ($ HTTP_POST_VARS) $ long. = $ value;
$ Hash = md5 ($ long );
Setcookie ("lasthash", $ hash, time () + 60*60*24*30); // reset the cookie
}
If ($ lasthash! = $ Hash ){
// Perform further operations on the data if the MD5 values are different twice
}
Else {
// If the two MD5 values are the same, the user is notified that the submission failed.
}
//......
?> |