Created
September 3, 2013 07:52
-
-
Save mdjhny/6420833 to your computer and use it in GitHub Desktop.
防止用户恶意或者重复提交数据,进行code验证
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$salt = 'qwerty'; | |
if (!empty($_GET['code'])) { | |
$code = $_GET['code']; | |
list($time, $encode) = explode('_', $code); | |
if ($encode != md5($time . $salt)) { | |
echo '非法请求'; | |
exit(); | |
} | |
echo '请求成功'; | |
} else { | |
$time = time(); | |
$code = $time . '_' . md5($time . $salt); | |
$link = "http://localhost/test.php?code={$code}"; | |
echo "<a href={$link}>{$link}</a>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment