使用PHP SELF时,PHP页面变白

时间:2014-07-18 22:41:42

标签: php html css

我正在尝试这样做,因此我的下拉列表(针对用户)会根据他们是否已登录进行更改... 所以,如果他们是,它会说出他们的名字和他们的个人资料的链接,然后是一个表格登录或注册,如果他们没有登录。问题是当我使用PHP_SELF它使整个页面变白和空白

我曾经拥有的东西:echo '<form action="" method="post">';
导致问题的原因echo '<form action="<?php echo htmlentities($_SERVER['PHP_SELF']);?>" method="post">';

<?php
    //checks cookies to make sure they are logged in
    if(isset($_COOKIE['ID_my_site'])) {
            $username = $_COOKIE['ID_my_site'];
            $pass = $_COOKIE['Key_my_site'];
            $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
                    while($info = mysql_fetch_array( $check )) {
                    //if the cookie has the wrong password, they are taken to the login page
                    if ($pass != $info['password']) {
                            //nothing here
                            } else {
                                    echo "" . $username . "<a href=\"http://www.skruffysdev.com/profile.php\">Profile</a>";
                            }
                    }
            } else {
                    echo '<form action="" method="post">';
                    echo '<h3 style="margin-top: 0px">Login</h3>';
                    echo '<input class="form-control" type="text" name="username" placeholder="Username"><br>';
                    echo '<input class="form-control" type="password" name="password" placeholder="Password"><br>';
                    echo '<div>» <a href="/forgot">Forgot Password</a></div><br>';
                    echo '<input type="submit" class="btn btn-primary" value="Login"> ';
                    echo '<a href="/help/register" class="btn btn-default">Register</a>';
                    //if the login form is submitted
            }
    ?>

有谁知道为什么会这样做以及如何解决?

0 个答案:

没有答案
相关问题