I created a login page.
I want customer and manager to login from this same page. I separated customer and manager in db by their role "","manager" respectively (customer represented as null value).
I wrote this code but its not working as i expected. When I type name and password and press login button it doesn't go to desired page rather it remains on login page.
<?php
session_start();
$db=mysqli_connect("localhost","root","","authentication");
if (isset($_POST['login_btn'])) {
$customer_name = mysql_real_escape_string($_POST['customer_name']);
$password = mysql_real_escape_string($_POST['password']);
$password=md5($password);
if(empty($customer_name)&&empty($password)) {
$error="Fields are Mandatory";
} else {
$sql="SELECT *
FROM customers
WHERE customer_name='$customer_name' AND password='$password'";
$result=mysqli_query($db,$sql);
$row=mysqli_fetch_array($result);
$_SESSION['id']=$row['id'];
$_SESSION['role']=$row['role'];
$count=mysqli_num_rows($result);
if($count==1){
if ($row['role']=="manager"){
header("location:manager.php");
}
else if($row['role']==""){
header("location:ueser.php");
}
}else{
$error='Customer_name/password combination incorrect';
}
}
}
?>