How to implement rights management function in PHP

一个新手
Release: 2023-03-16 12:18:01
Original
3082 people have browsed it

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

    权限管理  
  

用户与角色管理


query(,0( "{[1]}"?>


Copy after login

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

        
   

用户登录

Copy after login

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 "

{ $v[1] }

"; } ?>
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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!