controlling/creating accounts with privileges


Posted on 16th Feb 2014 07:03 pm by admin

hi all,
i'm trying to figure out how i can create/control account with privileges, for instance an Administrator creates an account but gives it guest privileges (able to see data but not edit, or delete it, not able to create users).

when a user logs in, i store his/her privileges is a session.
Did you know?Explore Trending and Topic pages for more stories like this.
Code: $_SESSION['staff_privilege'] = $found_user['privilege'];
i wrote this function to check for privileges and placed it in the create user page. (1 = admin, 2 = guest)
Code: function get_privilege() {
if (logged_in() && isset($_SESSION['staff_privilege'])) {
if ($_SESSION['staff_privilege'] == 2) {
redirect_to("../staff/staff_browse.php?privilege=false");
}
} else {
redirect_to("../staff/index.php");
}
}

for instance if a user with guest privileges goes to create user page, he/she will get redirect to another page showing a message.

the above code is working, but i'm wanted other ideas about how this could be accomplished in another way
thanks
No comments posted yet

Your Answer:

Login to answer
142 Like 29 Dislike
Previous forums Next forums
Other forums

Registration
ok so i have a site where people can register and login which works now thanks to someone on here th

Select question
Hi,

First I would like to say that php is pretty new for me..
so please don't shoot me if

parameter passing issue on function
Well I thought I had created a pretty slick web page, using ?page and $_GET to load pages which wher

Display the user's weight lost in the past week
Hello everyone,

I am working on a weight loss app for my site, and I want to display the user

Grabbing Values From an Array for Posting
I have a grid array that I am using with a form that when it hits the currently named test.php it lo

read integers that returns a negative or prints the average
Im trying to finish this homework assignment by tommarow afternoon and I keep getting stuck.
Wr

RTF fomatting to email content
Im trying to sen an email with content is picked up from a rtf-file (file_get_contents('*.rtf'). Mai

Code Review - SQL and Insertion Attacks (Warning: Not for Newbs)
Hey guys,

Its been a while, I know. Use to love coming here to answer peoples questions, but

FILTER_CALLBACK -- Files?
Hi All,

I'm using the php filter functions to validate my form data. For custom filters, I'm

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash