Implementation code based on php permission assignment-PHP Tutorial-php Tutorial

Source: Internet
Author: User
Implementation code based on php permission assignment. Today, I wrote down my thoughts on how to allocate my own permissions to the background Administrator. copy the code as follows :? Php ** reader * is a simple function implemented by Xiaobian. * First, each topic Today, I wrote down my thoughts on how to assign the background administrator permissions.

The code is as follows:


/** Reader
* The idea of Xiaobian is simple to implement.
* The ID number of each topic is fixed and then the administrator
* After creating an administrator, select the corresponding topic when assigning permissions to the administrator.
* In this way, the column id is inserted into the database. after the administrator logs on to the database
* Obtain the topic id that the administrator should have. The left-side navigation pane is displayed based on the current topic id.
* Check whether the column ID is displayed or not ..
*/
Header ("Content-type: text/html; charset = utf-8 ");
Error_reporting (E_ERROR );
$ Act = $ _ GET ['AC'];
$ Conn = mysql_connect ('localhost', 'root', 'root ');
Mysql_select_db ('study ', $ conn );
Mysql_query ('set names utf8 ');
If ($ act = "add") {// Here is the method to add
$ Prom = $ _ POST ['Prom '];
/*
After obtaining the column id, split the array into strings and insert it to the database.
Because the database does not provide the field type for inserting arrays
*/
$ Par = implode (',', $ prom );
// Here, the admin user is used as an example.
$ SQL = "insert into rc_admin (admin_name, pres) values ('admin', '$ par ')";
Mysql_query ($ SQL );
If (mysql_insert_id ()> 0 ){
Echo "success ";
} Else {
Echo "error ";
}
}
?>


This is the permission assignment page. if this option is selected, it indicates that the administrator has the permission assigned by the admin)


The navigation bar on the left obtains the cookie of this administrator after an administrator logs on.

The code is as follows:


// The cookie value obtained after logon.
$ SQL = "select * from rc_admin where adminid = 1 ";
$ Res = mysql_query ($ SQL );
$ List = mysql_fetch_assoc ($ res );
/*
Or use explode to split the data into arrays.
Then, determine whether the column id value is not in the array.
*/
$ Pros = $ list ['Pres'];
$ Pros = explode (',', $ pros );

// Use the in_array () function to determine if the column id is not in the $ pros field and is not displayed.


















}?> }?> }?>

Rewards for recruitment
Add a reward enterprise
Manage reward companies
Manage reward positions


This is the navigation bar on the left.


Here, the corresponding topic is displayed based on the administrator's logon permissions ..


The pipeline code is as follows :? Php/** reader * the idea of the mini-editor is relatively simple to implement * First, each topic...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.