這裡分析了php的簡單防盜鏈實作方法。分享飛大家供大家參考。具體如下:
index.php頁面如下:
<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頁如下:
$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"){//此處可替換成當(dāng)前使用的域名
echo "驗證錯誤!";
echo "<script>alert('連接失敗');location.href='index.php';</script>";
exit;
}
print("
");
?希望本文所述對大家php程式設(shè)計有所幫助。
以上就介紹了PHP用戶驗證 php簡單防盜鏈驗證實作方法 原創(chuàng),包括了PHP用戶驗證方面的內(nèi)容,希望對PHP教程有興趣的朋友有所幫助。