首页 > 解决方案 > 密码验证不提供任何输出作为回报并且没有显示错误

问题描述

即使我对密码和哈希本身的值进行硬编码,Password_verfiy 也根本不起作用。它正在一个类似的程序中工作,但该程序没有参数化查询

<?php
include 'db.php';
session_start();
$numrows=null;
$hpass=null;
if ($_SERVER['REQUEST_METHOD']=='POST') {
    if (!empty($_POST['user']) && !empty($_POST['pass'])) {
        $username = $_POST['user'];
        $password = $_POST['pass'];
        $query = $connection->prepare('Select password from users where username=?');
        $query->bind_param("s", $username);
        $query->execute();
        $query->bind_result($hpass);
        while ($query->fetch()) {
            $numrows++;
        }

        $query->close();
        //$query->fetch();
        //$numofrows=$query->num_rows;
        if ($numrows == 1) {
            if (password_verify($password, $hpass)) {
                $_SESSION['login_user'] = $username;
                header("location:todo.php");
            } else {
                header("location:1.php");
            }
        } else {
            header("location:2.php");
        }
    }
    else {
        header("location:not.php");
    }
}
$password = $_GET['pass'];
        $hpass = password_hash($password, PASSWORD_DEFAULT);
        $query=$connection->prepare("insert into users (username,password) values (?,?)");
        $query->bind_param('ss',$name,$hpass);
        if ($query->execute()) {
            $query->close();
            header('location:index.php');
        } else {
            header('location:not.php');
        }

标签: phphtmlsqlite

解决方案


推荐阅读