dongxiong5546 2015-04-22 13:17
浏览 708

从SQlite数据库中检索用户名和密码

I'm using the below to check an SQLite database for a username and password, but for some strange reason, it's bringing back an error that the password is incorrect when I login on the website:

private function checkPasswordCorrectnessAndLogin()
{
    $sql = 'SELECT Username, Password
            FROM users
            WHERE Username = :Username
            LIMIT 1';
    $query = $this->db_connection->prepare($sql);
    $query->bindValue(':Username', $_POST['Username']);
    $query->execute();
    $result_row = $query->fetchObject();
    if ($result_row) {
        if (password_verify($_POST['Password'], $result_row->Password)) {
            $_SESSION['Username'] = $result_row->Username;
            $_SESSION['user_is_logged_in'] = true;
            $this->user_is_logged_in = true;
            return true;
        } else {
            $this->feedback = "Incorrect Password.";
        }
    } else {
        $this->feedback = "User Does Not Exist.";
    }

    //default return
    return false;
}

I have no error with the username, it just states that the password is incorrect yet it is not; could anybody shine any light on why I'm receiving this error? I'm using the db browser to insert username and passwords into the table...

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制