php判断正常访问和外部访问的示例_php技巧
程序员文章站
2022-04-29 13:12:41
...
php判断正常访问和外部访问
session_start();
if(isset($_POST['check'])&&!empty($_POST['name'])){
if($_POST['check'] == $_SESSION['check']){
echo "正常访问";
}else{
echo "外部访问";
}
}
$token = md5(uniqid(rand(),true));
$_SESSION['check'] = $token;
?>
复制代码 代码如下:
session_start();
if(isset($_POST['check'])&&!empty($_POST['name'])){
if($_POST['check'] == $_SESSION['check']){
echo "正常访问";
}else{
echo "外部访问";
}
}
$token = md5(uniqid(rand(),true));
$_SESSION['check'] = $token;
?>
上一篇: 实现树状结构的两种方法