I am trying to make a login system for normal user and AdminUser. If a normal user types in browser http://localhost/project the login screen comes in and user can login using his Id and Password. But while logged in if user types in browser http://localhost/project/admin the normal user also gets the access in adminpanel which i want to stop. How can I do that ?I am stuck here for long time. Any Help Please?
Login for user:
$query = "SELECT * FROM user WHERE eid='$eid'and password='$password'";
$result = $db->select($query);
if ($result != false) {
 $value = $result->fetch_assoc();
 Session::set("login", "userLogin");
 Session::set("username", $value['username']);
 Session::set("email", $value['email']);
 Session::set("uid", $value['uid']);
 Session::set("image", $value['image']);
header("Location: index.php");
} else { $loginErr = "Username
or Password Not Matched !!";}
Session function for User:
public static function checkSession(){
 self::init();
 if (self::get("userLogin")!== false) {
 self::destroy();
 header("Location:login.php");
 }
}
Session check for User:
 Session::checkSession();
Login for admin
$query = "SELECT * FROM afcadmin WHERE adminname='$adminname'and password='$password'";
$result = $db->select($query);
if ($result != false) {
  $value = $result->fetchassoc();
  Session::set("loginadmin", "adminLogin");
  Session::set("adminname", $value['adminname']);
  Session::set("adminemail", $value['adminemail']);
  Session::set("adminid", $value['adminid']);
  header("Location: index.php");
  } else { 
      $loginErr = "Usernameor Password Not Matched !!";
      }
Session function for admin:
  public static function checkSessionAdmin(){
   self::init();
   if (self::get("adminLogin")!== false) {
   self::destroy();
   header("Location:login.php");
    }
   }
Session check for admin
 Session::checkSessionAdmin();
 
     
    