diff --git a/lib/account.php b/lib/account.php index c60d69d..c27aef3 100644 --- a/lib/account.php +++ b/lib/account.php @@ -105,19 +105,17 @@ function doLogin($email, $password): array $lastLoginAt = null; $loginCount = 0; $stmt->bind_result($uid, $first_name, $last_name, $nickname, $password_hash, $minecraft_nickname, $privilege_level, $lastLoginAt, $loginCount); + $stmt->fetch(); - if ($stmt->num_rows() > 0) { - echo "user found"; - $stmt->fetch(); - if (password_verify($password, $password_hash)) { - $found = true; + echo "user found"; + if (password_verify($password, $password_hash)) { + $found = true; - // Update LastLoginAt and LoginCount - $updateLoginStmt = $mysqli->prepare("UPDATE Users SET LastLoginAt = NOW(), LoginCount = LoginCount + 1 WHERE ID = ?"); - $updateLoginStmt->bind_param("i", $uid); - $updateLoginStmt->execute(); - $updateLoginStmt->close(); - } + // Update LastLoginAt and LoginCount + $updateLoginStmt = $mysqli->prepare("UPDATE Users SET LastLoginAt = NOW(), LoginCount = LoginCount + 1 WHERE ID = ?"); + $updateLoginStmt->bind_param("i", $uid); + $updateLoginStmt->execute(); + $updateLoginStmt->close(); } $_SESSION["ID"] = $uid;