I've done this sort of stuff this Python/Django a lot, but today I have to do this in PHP on an existing half-finished code. This is my first time with PHP.
Basically it's you usual login system, with admin login and user login.
My users table in my database contanins sno, username, password, admin, where admin is 1 for users with admin privileges.
Now while logging in, I understand I can simply check for the admin value for the whoever has logged in and header("Location: adminhome.php"); if admin and header("Location: userhome.php"); if not.
But how do I stop a regular user from accessing, say, adminpage1.php which is meant only for admins?
This is my first and only a one time job with PHP, otherwise I would go through various guid
$_SESSIONvar? If so, just put a check on the admin page forif (isset($_SESSION['username']) === false){ header('Location: /') }for example.