php判斷正常訪問和外部訪問的示例
更新時間:2014年02月10日 15:16:58 作者:
這篇文章主要介紹了php判斷正常訪問和外部訪問的方法,需要的朋友可以參考下
php判斷正常訪問和外部訪問
<?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;
?>
<form method="post" action="">
<input type="text" name="name"/>
<input type="text" name="check" value="<?=$token;?>">
<input type="submit">
復制代碼 代碼如下:
<?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;
?>
<form method="post" action="">
<input type="text" name="name"/>
<input type="text" name="check" value="<?=$token;?>">
<input type="submit">
您可能感興趣的文章:
相關文章
PHPStorm+Xdebug進行emote Debug時無法進入斷點問題排查
這篇文章主要介紹了PHPStorm+Xdebug進行emote Debug時無法進入斷點問題排查,遇到類似問題的同學,可以詳細參考下2021-04-04
PHP 5.5 創(chuàng)建和驗證哈希最簡單的方法詳解
最近 PHP 5.5.0 發(fā)布了,并帶來了一份完整的全新特性與函數(shù)的列表。全新API之一就是Password Hashing API.它包含4個函數(shù):password_get_info(), password_hash(), password_needs_rehash(),和password_verify().讓我們分步來了解每個函數(shù)2013-11-11
php 刪除一個數(shù)組中的某個值.兼容多維數(shù)組!
php中刪除一個數(shù)組中的某個值.兼容多維數(shù)組,需要的朋友可以參考下2012-02-02

