Home > php教程 > PHP源码 > PHP prevents external form submission | prohibits cross-site submission

PHP prevents external form submission | prohibits cross-site submission

大家讲道理
Release: 2016-11-08 17:25:53
Original
1664 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

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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template