Прежде всего, извините за мой плохой английский, я сделал страницу регистрации с помощью PHP и Mysqli, теперь, когда я хочу войти в систему, выдает ошибку login=error2
, я не могу выяснить, что не так с кодом.
Я уже погуглил проблему, и единственное, что я обнаружил, было то, что pwd varchar длиннее 255, я получил 256.
<?php
session_start();
if (isset($_POST['submit'])) {
include 'dbh.inc.php';
$uid = mysqli_real_escape_string($conn, $_POST['uid']);
$pwd = mysqli_real_escape_string($conn, $_POST['uid']);
//error handlers
//check if inputs are empty
if (empty($uid) || empty($pwd)) {
header("location: ../index.php?login=empty");
exit();
} else {
$sql = "SELECT * FROM users WHERE user_uid='$uid' OR user_email='$uid'";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck < 1) {
header("location: ../index.php?login=error1");
exit();
} else {
if ($row = mysqli_fetch_assoc($result)) {
// dehashing the password
$hashedPwdCheck = password_verify($pwd, $row['user_pwd']);
if ($hashedPwdCheck == false) {
header("location: ../index.php?login=error2");
exit();
} elseif ($hashedPwdCheck == true) {
// log in the user here
$_SESSION['u_id'] = $row['user_id'];
$_SESSION['u_first'] = $row['user_first'];
$_SESSION['u_last'] = $row['user_last'];
$_SESSION['u_email'] = $row['user_email'];
$_SESSION['u_uid'] = $row['user_uid'];
header("location: ../index.php?login=succes");
exit();
}
}
}
}
} else {
header("location: ../index.php?login=error");
exit();
}
Есть 3 сообщения об ошибках, я получаю сообщение header("location: ../index.php?login=error2");
.