Hello,
I created a user login form with a crietaria fixed that if the user type is admin then it should be redirected to admin page and if it is an agent it should be redirected to home.php
The admin type is working properly but when i enter agent id and paw it redirects back to login page
here is the code
<?php
include_once ("connection.php");
$username = $_POST["user_name"];
$password = $_POST["password"];
$query = "SELECT * FROM agents";
$query_confirm = mysqli_query($connection, $query);
while ($record = mysqli_fetch_assoc($query_confirm)) {
$id = $record["id"];
$uname = $record["agent_uname"];
$user_pass = $record["agent_password"];
$user_type = $record["user_type"];
}
if(isset($_POST["login"])) {
if($username == $uname && $password == $user_pass) {
if($user_type == "Admin") {
header("Location: ../admin.php?admin=".$id);
exit;
} else {
header("Location: ../home.php?agent=".$id);
exit;
}
} else {
header("Location: ../login.php");
}
}
?>
Thank You