Home >php教程 >PHP源码 >防止外部提交表单|禁止跨站提交

防止外部提交表单|禁止跨站提交

PHP中文网
PHP中文网Original
2016-05-25 17:09:43933browse

防止外部提交表单|禁止跨站提交

$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : NULL; 
$host = $_SERVER['HTTP_HOST']; 
echo '提交过来的地址:'.$referer; 
echo &#39;<br>&#39;; 
echo &#39;本站域名:&#39;.$host; echo &#39;<br>&#39;; 
echo substr($referer,7,strlen($host)); 
if(substr($referer,7,strlen($host)) != $host){ 
 echo &#39;非法操作&#39;; 
}else{ 
 echo &#39;正常操作&#39;; 
}

                   

 以上就是防止外部提交表单|禁止跨站提交的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn