2012-11-22 69 views
0
獨特的網頁

,當我登錄...我想它來尋找我的新$ _SESSION變量,然後重新裝入該頁面與所有選定的數據。但不是http://www.theqlick.com/findFriends/lesson.php?username=noahtheteacher重定向到

我得到這個代替:http://theqlick.com/findFriends/lesson.php?username=%3C?%20echo%20noahtheteacher;%20?%3E

這是爲什麼?它沒有加載正確的頁面要麼...我的代碼如下

頁面的頂部:

 $new_user = $_SESSION['user_login']; 

     if (!isset($_SESSION["user_login"])) { 
     echo ""; 
     } 
     else 
     { 
    echo "<meta http-equiv=\"refresh\" content=\"0; url=lesson.php?username=<? echo $new_user; ?>\">"; 

     } 

登錄實際的html代碼:

 <h2>If your a teacher, login below ...</h2> 
     <form action="lessons_login.php" method="post" name="form1" id="form1"> 
      <input type="text" size="40" name="user_login" id="user_login" class="auto-clear" title="Username ..." /><p /> 
      <input type="text" size="40" name="password_login" id="password_login" value="Password ..." /><p /> 
      <input type="submit" name="button" id="button" value="Login to your account"> 
     </form> 
     </div> 
+0

回聲 「」; –

回答

0

更換你下面一行:

echo "<meta http-equiv=\"refresh\" content=\"0; url=lesson.php?username=<? echo $new_user; ?>\">"; 

這一個:

echo "<meta http-equiv=\"refresh\" content=\"0; url=lesson.php?username=$new_user\">"; 

由於您不需要使用<? echo $new_user; ?>語法,因爲該語法用於將html代碼嵌入到PHP代碼中,而不是像PHP那樣使用PHP本身。

1

由於@nelson建議,你有一個已經被解析線內標籤。因此,解釋器不會將其解析爲開始和結束標籤,而是將其作爲要回顯的字符。

我進一步建議你使用雙引號來打開和關閉你的路線,那裏面然後單引號,這樣你就不必逃避它們。然後,在變量周圍放置{}以確保正確解析。

例如,

<?php 
echo "<a href='www.example.com'>{$my_variable}</a>"; 
?>