hain Posted May 29, 2020 Share Posted May 29, 2020 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> Quote Link to comment https://forums.phpfreaks.com/topic/310863-i-need-code-that-reads-from-the-role-database-and-displays-the-file-according-to-it/ Share on other sites More sharing options...
gw1500se Posted May 29, 2020 Share Posted May 29, 2020 So what did you try and what did you get that you did not expect? Quote Link to comment https://forums.phpfreaks.com/topic/310863-i-need-code-that-reads-from-the-role-database-and-displays-the-file-according-to-it/#findComment-1578490 Share on other sites More sharing options...
hain Posted May 29, 2020 Author Share Posted May 29, 2020 I tried the session but it didn't work out, so I deleted the code and went here to ask if anyone was able to write me what I needed. Quote Link to comment https://forums.phpfreaks.com/topic/310863-i-need-code-that-reads-from-the-role-database-and-displays-the-file-according-to-it/#findComment-1578495 Share on other sites More sharing options...
Barand Posted May 29, 2020 Share Posted May 29, 2020 Assign role to users Have an access table to define which roles can access which files (As requested, all tables are accessible via PDO) +-------------+ +---------------+ +--------------+ | user | | role | | file | +-------------+ +---------------+ +--------------+ | user_id | +------| role_id |-+ +---| file_no | | username | | | description | | | | filename | | password | | +---------------+ | | +--------------+ | role_id |>-----+ | | +-------------+ | | | +-------------+ | | | access | | | +-------------+ | +--<| role_id | | | file_no |>-+ +-------------+ 1 Quote Link to comment https://forums.phpfreaks.com/topic/310863-i-need-code-that-reads-from-the-role-database-and-displays-the-file-according-to-it/#findComment-1578496 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.