php - 密码验证不提供任何输出作为回报并且没有显示错误
问题描述
即使我对密码和哈希本身的值进行硬编码,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');
}
解决方案
推荐阅读
- c - 在 C 中定义和初始化一个字符串数组
- java - 将 SwipeView 放在片段中?
- bash - 如何从 Nginx 运行 bash 脚本
- python - 防止 docker-compose 在使用构建的图像时重新安装 requirements.txt
- hangouts-chat - 如何通过 API 创建带有视频会议链接的环聊聊天消息
- javascript - 运行节点文件参数时切断双引号
- batch-file - 如何在 shell 中运行批处理?
- spring - Spring JpaRepository - findByParam(字符串参数)不区分大小写
- scala - `_corrupt_record: string (nullable = true)` 带有一个简单的 Spark Scala 应用程序
- sql - 在 Identity Server 4 中放置用户声明的位置