Home > Article > Backend Development > PHP user verification PHP simple anti-hotlink verification implementation method original
Here is an analysis of the simple anti-hotlink implementation method of PHP. Share it with everyone for your reference. The details are as follows: The
index.php page is as follows:
<html> <head> <meta http-equiv="Content-Language" c /> <meta name="GENERATOR" c /> <meta http-equiv="Content-Type" c /> <title>防盗链</title> </head> <body> <form action="check.php" method="post"> 提交信息:<input type="text" name="name" value=""/> <input type="submit" name="submit" value="提交"/> </form> </body> </html>
check.php page is as follows:
$urlar=parse_url($_SERVER['HTTP_REFERER']); print("<pre class="brush:php;toolbar:false">"); print_r($urlar); print_r($_SERVER['HTTP_REFERER']); if($urlar['host']!="localhost"){//此处可替换成当前使用的域名 echo "验证错误!"; echo "<script>alert('连接失败');location.href='index.php';</script>"; exit; } print("");
I hope this article will be helpful to everyone in php programming design.
The above introduces the PHP user verification and PHP simple anti-hotlink verification implementation method. Original, including the content of PHP user verification. I hope it will be helpful to friends who are interested in PHP tutorials.