-2

我的 login.PHP 页面返回空白。我试过改变我能想到的一切。我知道我可能只是缺少一些简单的东西。它应该返回错误。这是 login.PHP 的代码(我还打开了一个单独的错误报告器来查看我得到了什么错误并且我得到了“array()”

include 'core/init.php';

if (empty($_post) === false){
    $username = $_post['username'];
    $password = $_post['password'];

    if (empty($username)=== true || empty($password) === true) {
        $errors[] = 'You need to enter a username and password.';
    }
    else if (user_exists($username) ===false) {
        $errors[] = 'We can\'t find that username. Have you registered?';
    }
    else if (user_active($username) ===false){
        $errors[] = 'You haven\'t activate your account yet.';
    } 
}

print_r($errors);
ini_set('display_errors',1); 
error_reporting(E_ALL);

提前谢谢!

4

4 回答 4

1
  1. 使用 $_POST 而不是 $_post
  2. 使用$username = isset($_POST["username"]) ? $_POST["username"] : false;然后问if ($username)
  3. 在询问 DB 之前不要忘记清理输入
于 2013-03-11T23:16:27.383 回答
0
if (empty($_post) === false){
$username = $_post['username'];
$password = $_post['password'];

应该

if (empty($_POST) === false){
$username = $_POST['username'];
$password = $_POST['password'];

尝试添加更多详细信息以查看 if 语句的结束位置,或者var_dump($_POST)var_dump($errors)

于 2013-03-11T23:05:51.813 回答
0

$_POST['...'] - 总是用户大写,

$_GET['...'] - 也是

于 2013-03-11T23:16:04.907 回答
0

尝试使用 $_POST(全部大写)。

函数不区分大小写,但变量不区分大小写。

于 2013-03-11T23:12:58.393 回答