PHP脚本报告错误的凭据

时间:2015-07-14 09:30:57

标签: php mysql

好的,这是我的身份验证代码。现在,我有一个表和5个PHP工作脚本,除了这个。成功登录后,用户应该被重定向到他的主页,但问题是,PHP回应"无法登录"错误消息,无论登录详细信息。继承剧本:

session_start();
include_once'dbconnect.php';
    if (isset($_SESSION['user']) != "") {
        header ("Location: home.php");  
    }

    if (isset($_POST['login'])) {
        $email = mysql_real_escape_string($_POST['email']);
        $pass = mysql_real_escape_string($_POST['pass']);
        $sql = mysql_query("SELECT * FROM users WHERE email='".$email."'");
        $num = mysql_fetch_assoc($sql);

            if ($num['password'] == $pass)) {
                $_SESSION['user'] = $num['user_id'];
                header ("Location: home.php");
            }
                else {
                    echo "Cannot login";
                }
    }

任何提示?谢谢

2 个答案:

答案 0 :(得分:0)

/my-url

确保从数据库中获取密码。

答案 1 :(得分:0)

1.I think Your password encrypted in db.

2.Check it out it may be md5,sha etc.

3.If yes. Change Like this

 if ($num['password'] == md5($pass)){
     .
     .
     .
     .
 }

希望它有助于......