方法一:
你可以把處理提交數據的代碼寫到一個單獨的文件裡
<?php
if (defined(’INSIDE’)) {//判斷是否有定義INSIDE常量
//處理表單
} else {
exit(’錯誤’);
}
?>
然後
define(’INSIDE’
接著
include ’form
======================================================================================= 方法二:
<?php
if(PHP_VERSION<’
if(isset($_SERVER["HTTP_REFERER"])){
//針對部分浏覽器可能無HTTP_REFERER
$servername=$_SERVER[’SERVER_NAME’];
$sub_from=$_SERVER["HTTP_REFERER"];
$sub_len=strlen($servername);
$checkfrom=substr($sub_from
if($checkfrom!=$servername)
{
echo "<script language=’javascript’>window
exit;
}
}
?>
此方法並非絕對安全
From:http://tw.wingwit.com/Article/program/PHP/201311/21219.html