Here we analyze the simple anti-theft chain implementation method of php. Share with you for your reference. The details are as follows:
The page is as follows:
<html> <head> <meta http-equiv="Content-Language" content="en" /> <meta name="GENERATOR" content="PHPEclipse 1.0" /> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Anti-theft chain</title> </head> <body> <form action="" method="post"> Submit information:<input type="text" name="name" value=""/> <input type="submit" name="submit" value="submit"/> </form> </body> </html>
The page is as follows:
$urlar=parse_url($_SERVER['HTTP_REFERER']); print("<pre>"); print_r($urlar); print_r($_SERVER['HTTP_REFERER']); if($urlar['host']!="localhost"){//This can be replaced with the currently used domain name echo "Verification error!"; echo "<script>alert('Connection failed');='';</script>"; exit; } print("</pre>");
I hope this article will be helpful to everyone's PHP programming.