2014-02-14 61 views
0

我目前正在忙於我的index.php以包括通過$_GET請求的文件。 唯一的問題是它總是返回admin,並且從不返回$_GET變量中聲明的值。

所有文件都位於用作子域的目錄中。

Warning: include(pages/admin.php): failed to open stream: No such file or directory in /home/tjattern/domains/*censored*/public_html/admin/index.php on line 20

我請求http://admin.*censored*.nl/index.php?page=dashboard

index.php

<?php 

error_reporting(E_ALL); 
ini_set('display_errors', 1); 

// include required files 
require_once('core/config.php'); 
require_once('template/tpl_top.php'); 


if(isset($_COOKIE['as'])) 
{ 
    if(isset($_GET['page'])) 
    { 
     $file = "pages/".$_GET['page'].".php"; 
    if(file_exists($file)) 
    { 
     include($file); // actual line 20 
    } 
    else 
    { 
     echo 'This page could not be found'; 
    } 
    } 
    else 
    { 
     include('pages/dashboard.php'); 
    } 
} 
else 
{ 
include('pages/login.php'); 
} 


require_once('template/tpl_bot.php'); 

?> 
+0

是index.php的全部內容嗎?如果是這樣,錯誤出現在另一個文件中。您應該在嘗試包含之前檢查文件是否存在。 –

+1

你要求的URL是什麼?你是否拋出了$ _GET後續代碼var_dump($ _ GET);?是你的.htaccess重寫你的網址?你也可以把include包裝在is_file中('pages /'.$_ GET''page']。'。php');實際檢查文件是否存在。 – Springie

+0

更新了代碼,插入完整的index.php - 主目錄中有一個htaccess,是否也會影響子目錄?當我轉儲var時,它也給了我管理員。 –

回答

1

http://ww.example.com/index.php?page=sample

請求這個網址

$ _GET [ '頁']在指數。 php結束將是「樣本」

您是否在頁面屬性中傳遞正確的值?

+0

應該評論。 – Rikesh

+0

低於代表50:P –

+0

是的,我正在向您的網址傳遞正確的敬意。 –