2013-03-14 20 views
0

我有這個代碼顯示特定的內容登錄用戶。然而,使用這個我不能在頁面上包含其他的PHP文件。無論如何要重寫這個,所以我可以使用包含函數。我該如何重寫這個只有PHP成員的頁面腳本?

<?php 
    if($_SESSION['id']) 
     echo '<div id="center" class="column">center here</div> 
      <div id="left" class="column">leftbar here</div> 
      <div id="right" class="column">rightbar here</div>'; 
    else 
     echo '<h1>Staff please, <a href="index.php">login</a> 
      before accessing this page, no access to students.</h1>'; 
?> 

目前,我不能把在那裏說:「這兒中心」,「leftbar這裏」和「rightbar這裏」這樣的:

`<?php include("center.php"); ?>` 

我是新來的這一切的東西,所以不要太複雜,謝謝!

+0

爲什麼你不能用'include'? – Kermit 2013-03-14 21:05:54

+0

@AarolamaBluenk我似乎在使用它們時會出現語法錯誤。 – 2013-03-14 21:48:15

回答

0

如果我理解正確的話,應該是這樣的:

<?php 
     if($_SESSION['id']) 
      echo '<div id="center" class="column">'; 
       include("center.php"); 
      echo'</div> 
       <div id="left" class="column">'; 
       include("leftbar.php"); 
     echo'</div> 
       <div id="right" class="column">'; 
      include("rightbar.php"); 
      echo '</div>'; 
     else 
      echo '<h1>Staff please, <a href="index.php">login</a> 
       before accessing this page, no access to students.</h1>'; 
?> 
+0

在代碼的'else'部分獲得語法,其餘部分看起來不錯。你建議我做什麼? – 2013-03-14 21:30:43

+0

@TomCarter語法錯誤;再次嘗試代碼。 – Kermit 2013-03-14 21:50:09

+0

仍然得到該代碼的語法錯誤:/ – 2013-03-14 22:03:19

相關問題