<?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">
URL:http://www.bianceng.cn/webkf/PHP/201410/45949.htm