Skip to content

Instantly share code, notes, and snippets.

@mdjhny
Created September 3, 2013 07:52
Show Gist options
  • Save mdjhny/6420833 to your computer and use it in GitHub Desktop.
Save mdjhny/6420833 to your computer and use it in GitHub Desktop.
防止用户恶意或者重复提交数据,进行code验证
<?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