Hello.
I am having some trouble stopping Logged in Users from accessing Admin Pages, and Vice Versa. I think it is the way im trying to determine the $logged_in value, but have tried every way i know how and its not working.
In its most basic form i have:
Student_login.php
check_login.php
test_student.php
and
admin_login.php
check_admin.php
test_admin.php
The check files are included on every page, as they have my connection string in there, and also decide if the user is logged in or not.
If not $logged_in is set to 0. Otherwise check_login sets it to 1, for a successful login, and chec_admin sets $logged_in to 2.
Now when i test this, and log in as a student, i can access the test_admin page. and same for the other way around.
This is in the test_admin.php page, ive tried every way of wording the if statement.
<?php
include('check_admin.php');
if ($logged_in !==2) {
die('<p> Sorry you are not logged in, this area is restricted to registered members. <p> <a href="login_admin.php">Click here</a> to log in.');
}
?>
Heres the code from test_student.php
<?php
if ($logged_in !==1) {
die('<p> Sorry you are not logged in, this area is restricted to registered members. <p> <a href="login_admin.php">Click here</a> to log in.');
}
?>
If i dont log into either login, then i get the correct error messages, but logging into 1, seems to log me into both.
Also when my login.php pages load....if im logged into admin, the student login says im logged in already.
but they have these in place...
Admin_login.php
if($logged_in == 2)
{
die('already logged in etc...
student_login.php
if($logged_in == 1)
{
die('
Any ideas please?