-3

说到我的最后一个代码,它不会将我的登录页面指向 index.php 吗?你认为问题出在header()功能上吗?

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

        if(empty($username)=== true || empty($password)=== true){
            $errors[] = 'You need to enter a user name and password';
        }else if(user_exists($username)===false){
            $errors[] = 'we can\'t find that username. Have you registed?';
        }else if(user_active($username)===false){
            $errors[] = 'You have\'t activated your account ! please check your email and active it';
        }else{
            $login = login($username,$password);
            if($login === false){
                $errors[] = "That username/password combination is not correct";
            }else{                  
                $_SESSION['id'] = $login;
                header('Location:index.php');
                exit();
            }
        }       

        print_r($errors);
    }

?>
4

1 回答 1

0

如果你想检查header()功能是否有效。首先删除所有if-else conditionsand thanheader()功能肯定会起作用。而不是if-else condition一一给出echo or print一些值来检查响应。

于 2013-03-30T07:36:25.867 回答