surveen Posted December 3, 2014 Share Posted December 3, 2014 Hello All, I have designed a small php module Which has more than 80 .php files. I want to give the access level for all those files through a global access.php file. But i am not getting how it can be developed. I made a table in database which has all the scripts name. When those are checked value 1 it has to be visible for those users who come under a perticular position like MD, CEO, Sales Manager etc. Here is my table structure and i tried doing like this if($_SESSION['pos']=='admin') { echo "<h1> SORRY YOU DONT HAVE ACCESS </h1>"; } else { // file contents... } But this will become manual and also for single position ie 'admin'. Can somebody show me the path how it has to be structured and how these accessibility can be done. Thanks Quote Link to comment Share on other sites More sharing options...
surveen Posted December 3, 2014 Author Share Posted December 3, 2014 Can somebody please help Quote Link to comment Share on other sites More sharing options...
maxxd Posted December 3, 2014 Share Posted December 3, 2014 You could associate a number with the position (usually called a 'role') and then decide permissions based on that number. For instance, if role 'admin' has a level of 1000 and role 'CEO' has a level of 900, then a page with an access level of 950 will be viewable to admin users but not CEO users. Something like this: $pageAccessLevel = $queryResults['access_level']; $userLevel = $_SESSION['role_level']; if($pageAccessLevel > $userLevel){ print("<p>You have insufficient rights to view this page. Begone!</p>"); die(); } // rest of page script... Quote Link to comment 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.