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

PHP prevents external form submission | prohibits cross-site submission

大家讲道理
大家讲道理Original
2016-11-08 17:25:531584browse

$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;;
}

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
Previous article:PHP remove BOM headerNext article:PHP remove BOM header