prepare($query); $stmt->bind_param("s", $username); $stmt->execute(); $stmt->bind_result($user_id, $user_username, $user_password, $user_isAdmin); // Fetch the result if ($stmt->fetch() && password_verify($password, $user_password)) { $_SESSION['user_id'] = $user_id; header('Location: index.php'); exit(); } else { echo "Invalid username or password."; } // Close the statement $stmt->close(); } ?>