// Fetch values
mysqli_stmt_fetch($stmt);
// Verify the password
if (password_verify($password, $db_password)) {
// Password is correct
// Store user information in session variables
$_SESSION["firstname"] = $firstname;
$_SESSION["lastname"] = $lastname;
$_SESSION["designation"] = $designation;
$_SESSION["role"] = $role;
$_SESSION["logged_in"] = true;
// Redirect the user based on their role
switch ($role) {
case "admin":
header("location: sprc.php");
exit();
case "state":
header("location: sprc.php");
exit();
case "lga":
header("location: sprc.php");
exit();
default:
echo "Unknown role!";
}
} else {
// If password is incorrect, set an error message
$wrong = "Wrong Username or Password";
}
// Close the statement
mysqli_stmt_close($stmt);
} else {
// If no matching row found, set an error message
$wrong = "Wrong Username or Password";
}
// Close the database connection
mysqli_close($conn);
}
// If there's an error message set, display it or handle it as needed
if (isset($wrong)) {
echo $wrong;
}
?>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX