简体   繁体   中英

user permissions

im doing project for a school...and new to php and mysql..just learning..

i have to create one loginpage with 3 different users like corres,principal and the staff

in the table field what type i have to give like ENUM or SET.. i want to assign 0 for corr,1 for princi and 3 for staff..

how to do this and shud i give any field in the login page in php??

but im going to create only 2 tables one for corr and other one is for staff

corr table fields r corrs_id,username,password,staff_id,staff_role

staff table fields r staff_id,staff_role,name,qualification,address,state etc...

both the tables have 2 common fields staff_id and staff_role now how to connect 2 tables and when username and password is given it shud first check the staff_role like 'princ' or a 'staff'

please help me....

  1. Don't keep two same fields in 2 tables if you can get rid of one. Read about database normalization first.

  2. Remove the staff_role field from the corr table and leave only the staff_id to join both tables as I said above.

  3. The two tables are joinable using this exact staff_id


select u.name,r.role from users u
inner join roles r
on u.role_id=r.id
where r.role='princ' and u.username='bleh' and u.password='bleh'

Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM