This article mainly introduces the implementation of PHP to prevent the recurrence of forms, combined with examples of PHP-based token verification to prevent the form of repeated submission of the relevant operation skills, very simple and practical, the need for friends can refer to the next
The example in this article describes the PHP implementation to prevent forms from repeating the submission feature. Share to everyone for your reference, as follows:
There are a number of ways to prevent forms from repeating submissions, so let's introduce how PHP can effectively prevent forms from repeating submissions today.
The code is very simple
I believe that we are very clever to share a small demo, we can learn from:
Specific code:
<?php/** September 29, 2016 08:09:13*/session_start (); Header ("content-type:text/html;charset=utf-8"); function set_ Token () {$_session[' token '] = MD5 (Microtime (TRUE));} function Valid_token () {$return = $_request[' token '] = = = $_session[' token ']? True:false; Set_token (); return $return;} Generates a tokenif (!isset ($_session[' token ') "If token is empty) | | $_session[' token ']== ') {Set_token ();} if (Isset ($_post[' web ')) {if (!valid_token ()) {echo "token error, please do not repeat the submission!) "; }else{Echo ' successfully submitted, Value: '. $_post[' web '; }}else{?><! DOCTYPE html>
The above is the whole content of this article, thank you for reading. Read more about topic.alibabacloud.com!