What I do is to put all these
Index.php
<?php
include('includes/navbar.php');
?>
<!-- Main Content -->
<?php
include('includes/footer.php');
?>
page2.php
<?php
include('includes/navbar.php');
?>
<!-- Main Content -->
<?php
include('includes/footer.php');
?>
page3.php
<?php
include('includes/navbar.php');
?>
<!-- Main Content -->
<?php
include('includes/footer.php');
?>
page4.php
<?php
include('includes/navbar.php');
?>
<!-- Main Content -->
<?php
include('includes/footer.php');
?>
Page5.php
<?php
include('includes/navbar.php');
?>
<!-- Main Content -->
<?php
include('includes/footer.php');
?>
code.php Here is the code where for validating if the user is an admin or non-admin user The !password_verify is for validation for password and hash password.
if(isset($_POST['login_btn']))
{
$email_login = $_POST['emaill'];
$password_login = $_POST['passwordd'];
$query = "SELECT * FROM register WHERE email='$email_login' LIMIT 1";
$query_run = mysqli_query($connection, $query);
$password = "SELECT password FROM register WHERE email='$email_login'";
$usertypes = mysqli_fetch_array($query_run);
if($usertypes['usertype'] == "admin")
{
if(!password_verify($password_login, $password))
{
$_SESSION['username'] = $usertypes['username'];
header('Location: index.php');
}
else
{
$_SESSION['status'] = "Email / Password is Invalid";
header('Location: login.php');
}
}
else if ($usertypes['usertype'] == "user")
{
if(!password_verify($password_login, $password)){
$_SESSION['username'] = $usertypes['username'];
header('Location: index2.php');
}
else
{
$_SESSION['status'] = "Email / Password is Invalid";
header('Location: login.php');
}
}
}
UPDATE: I've already found a solution to the problem... Just put all the list items tag<li></li> inside this php elseif if you want to display a specific navbar list when an Admin user is logged in but want to hide them in a non-admin one.
<?php if($_SESSION['TYPE'] == 'admin'): ?>
<li class="nav-item">
<a class="nav-link" href="PageForAdmin.php">
<i class="fas fa-user" style="font-size: 20px;"></i>
<span>Page For Admin</span></a>
</li>
<?php endif; ?>