目前學習PHP和使用include
包括頁面元素,如保護包含在include中的頁面(「」);
include('menubar.php');
include('content.php');
include('footer.php');
它們都稱爲由說private.php
我想知道什麼,你認爲這是保護的最便捷的途徑這些頁面在打字的情況下example.com/content.php
我目前使用類似
<?php //
require("common.php");
// Check to see if the user is logged in
if(empty($_SESSION['user']) || $_SERVER['PHP_SELF'] == "content.php")
{
// if either is true redirect to index.php
header("Location: index.php");
die("Redirecting to index.php"); // login page
}
但想知道還有什麼我可以/應該做的?
注意:$ _SESSION ['user']在每個會話開始時或登錄時進行驗證。
對於離,如果你使用Apache,您可以使用htaccess的否認一切,但在這[文章]你的入口點狀(http://stackoverflow.com/questions/1340001/deny-直接訪問所有的PHP文件,除了index-php) –
謝謝丹,我想能夠設計登錄頁面,所以我遠離htaccess。 – denski