当我尝试登录verify_password编写的语句始终为false时,我遇到了问题。
<?php
if (isset($_POST['submit_login'])){
require 'connectionknygos.php';
$username = $_POST ['vardas'];
$password = $_POST ['slap'];
if(empty($username)||empty($password)){
header("Location: frontpage.php?error=emptyfields");
exit();
}
else{
$sql = "SELECT * FROM vartotojai WHERE username = ?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
header("Location: frontpage.php?error=sqlerror");
exit();
}
else{
mysqli_stmt_bind_param($stmt, 's', $username);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if($row = mysqli_fetch_assoc($result)){
$passwordCheck = password_verify($password, $row['password']);
if($passwordCheck == false){
header("Location: frontpage.php?error=wrongpasswordtest");
exit();
}
if($passwordCheck == true){
session_start();
$_SESSION['id'] = $row['id'];
$_SESSION['username'] = $row['username'];
header("Location: frontpage.php?login=success");
exit();
}
else{
header("Location: frontpage.php?error=wrongpassword");
exit();
}
}
else{
header("Location: frontpage.php?error=nouser");
exit();
}
}
}
}