当我登录时,我想用它找到我的新$_SESSION变量,然后用所有选定的数据重新加载到该页面中。而不是http://www.theqlick.com/findFriends/lesson.php?username=noahtheteacher
取而代之的是:http://theqlick.com/findFriends/lesson.php?username=%3C?%20echo%20noahtheteacher;%20?%3E
为什么会这样呢?它没有加载正确的页面either...my代码如下
页面顶部:
$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>发布于 2012-11-23 07:07:47
正如@nelson所建议的,在已经解析的行中有标记。因此,解释器不会将其解析为开始和结束标记,而是将其解析为要回显的字符。
我进一步建议您使用双引号来打开和关闭您的行,然后在其中使用单引号,这样您就不必转义它们。然后,用{}括起你的变量以确保正确的解析。
例如,
<?php
echo "<a href='www.example.com'>{$my_variable}</a>";
?>发布于 2012-11-23 07:02:28
替换您的以下行:
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\">";因为您不需要使用php语法,因为该语法用于在<? echo $new_user; ?>代码中嵌入PHP代码,而不是像您所做的那样嵌入PHP本身。
https://stackoverflow.com/questions/13521060
复制相似问题