Permission management system is mainly used to set different permissions for different users, so that users with different permissions can use different functions after logging in.
First look at the database





##There are a total of 5 tables, users, roles and roleswork 3 One table forms a "w"-shaped relationship with the other two tables, which is also a relatively common permission database method. First, the permissions are set, that is, the management sets different permissions for different users.
1. Administrator page RBAC.php
2. Administrator’s processing page RBchuli.php
StrQuery($sql,0);
Copy after login
Save role information processing page RBbtnchuli.php
query($sdel); //添加 foreach($arr as $v){ $sql = "insert into users_roles values(0,'{$uid}','{$v}')"; $db->query($sql); }
Copy after login
The effect is as shown:


The next thing to do is to log in to an account and view Own functions
3. User login page RBlogin.php
4. Login page processing page RBloginchuli.php
StrQuery($sql,0); if(!empty($pwd) && $pwd==$mm) { $_SESSION["uid"] = $uid; header("location:RBmain.php"); } else { echo ""; }
Copy after login
5. Finally, make the user’s main page RBmain .php
权限主页面
query($sql,0); foreach($arr as $v) { echo ""; } ?>
Copy after login
The effect is as shown in the figure:

The above is the detailed content of How to implement rights management function in PHP. For more information, please follow other related articles on the PHP Chinese website!