我的login.php似乎不起作用


My login.php does not appear to be working

我目前正在开发一个非常基本的登录系统,我知道这不是最好的方法,但目前我只想确保我掌握了它的窍门。我的login.php看起来是这样的。

<?php
        session_start();
        $the_username = "xxxx";
        $the_password = "12345";
        if ($_POST['username'] == $the_username ) &&
            ($_POST['password'] == $the_password) {
            $_SESSION['username'] = $username;
            header("Location: menu.php");
        }
        else { echo "Entry Denied"; return;}
    ?>

我的表格看起来像…

<form action="login.php" method="POST" >
    <input type="text" name="username" placeholder="Username"/>
    <input type="password" name="password" placeholder="Password"/>
    <input type="submit" name="Login" class="login" value="Login"/>
</form>

有人能解释一下为什么这似乎不起作用吗?

$username为空,但$_POST['username']是您要查找的