0

when I log in...i want to it to find my new $_SESSION variable and then reload into that page with all the selected data. But instead of http://www.theqlick.com/findFriends/lesson.php?username=noahtheteacher

I get this instead: http://theqlick.com/findFriends/lesson.php?username=%3C?%20echo%20noahtheteacher;%20?%3E

Why is that? It isn't loading the correct page either...my code is below

The top of the page:

      $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; ?>\">";

         }

The login actual html code:

        <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>
4

2 回答 2

1

正如@nelson 建议的那样,您在已经解析的行中有标签。因此,解释器不会将其解析为开始和结束标记,而是将其解析为要回显的字符。

我会进一步建议您使用双引号来打开和关闭您的行,然后在其中使用单引号,这样您就不必转义它们。然后,将 {} 放在变量周围以确保正确解析。

例如,

<?php
echo "<a href='www.example.com'>{$my_variable}</a>";
?>
于 2012-11-22T23:07:46.563 回答
0

Replace your following line:

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

for this one:

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

As you don't need to use the <? echo $new_user; ?> syntax because that syntax is used to embedded php code inside html code, not in PHP itself as you were doing.

于 2012-11-22T23:02:27.990 回答