I had a problem with multi level user login in PHP MySQL. I able to login with admin but nothing happen when im trying to login with different user. Is there something Im missing here?
Here is my code snippet
<form action="" method="post">
<div class="form-group">
<label for="inputUsername">Username</label>
<input type="text" class="form-control" name="username" placeholder="username" required>
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" name="password" placeholder="Password" required>
</div>
<div class="user_type">
<table>
<tr>
<td>User Type </td>
<td><select name="usertype" id="type">
<option value="-1"> Select user type</option>
<option value="customer">Customer</option>
<option value="landlord">Landlord</option>
<option value="admin">Admin</option>
</select></td>
<button type="submit" name="submit" class="btn btn-primary">Login</button>
<?php
include('connection.php');
if(isset($_POST['submit'])){
$username=$_POST['username'];
$password=$_POST['password'];
$type=$_POST['usertype'];
$query="SELECT * FROM `user_level` WHERE username='$username' and password='$password'
and type='$type'";
$result=mysqli_query($conn,$query);
while($row=mysqli_fetch_array($result)){
if($row['username']==$username && $row['password'==$password] &&
$row['type']=='Admin') {
header("Location: admin_mainpage.php");
} elseif($row['username']==$username && $row['password'==$password] &&
$row['type']=='Land Owner'){
header("Location: LO_mainpage.php");
}elseif($row['username']==$username && $row['password'==$password] &&
$row['type']=='Customer'){
header("Location: Customer_mainpage.php");
}
}
}
?>