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

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

PHP中文网
Release: 2016-05-25 17:09:43
Original
970 people have browsed it

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

$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;; 
}
Copy after login

                   

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

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template