I need code that reads from the role database and displays the file according to it

Hi, I need code that reads from the roles database and then selects which file from these 3 which I want. For example, the user.php file would be loaded if the user has UName = user, Pass = 124, and Roles = User added to the database. But the admin.php and boss.php files would not appear to him.
Then only the user who would have it like UName = admin Pass = 125 and Roles = Admin would see the admin.php file, but he would not see the user.php and boss.php files. And of course the boss.php file would be seen by a user with UName = boss, Pass = 126 and Roles = Boss.
Please use only PDO!
I need to write this in this code somehow.

    <?php
    session_start();

    if(!(isset($_SESSION['User'])))
    {
        header("Location: index.php");
        exit(0);
    }	  

?>
<!DOCTYPE html>
<html>
<body>
<?php 
include "config.php";
?>
<!--show for User-->
<?php include 'user.php';?>
<!--show for Admin-->
<?php include 'admin.php';?>
<!--show for Boss-->
<?php include 'boss.php';?>
</body>
</html>

What have you tried?

session but I can’t do it perfectly there so I can write it. That’s why I’m writing here if anyone could write me what I need.

You are already saying what the logic is, why can’t you write it?

hain,

this doesn’t use PDO, but does it really matter? https://stackoverflow.com/questions/3084481/php-login-and-get-user-information

isn’t this just an issue of including different files based on a DB return, as shown in that SO link?

if ($user = ‘whoever’ && $pass = ‘xxxxx’) {
include ‘user.php’;
}

I’m no expert, but astonecipher I think said it all, didn’t she?

Lock or delete topic please.

Sponsor our Newsletter | Privacy Policy | Terms of Service