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.
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

Count Session and Trigger Events
I am New in PHP, seeking a method to count logged users by counting the sessions or any …, is

C++ API to Oracle dB
I need to perform a select command to the Oracle dB to obtain information from a table.
What libr

matching numbers inside ( )
I know I can match numbers by just [0-9]+, so I thought matching numbers inside ( ) would be somethi

PHP Code To Change Font Color in Table Cell
I would appreciate help with the following snippet of my php code. I am just trying to change the f

Syntax Help
I'm trying to make a form that edits a php file which contains config settings. I'm using strings t

PHP and Javascript
Hi Guys,

Im trying to load the contents of an html file into a text area for editing, this is

Simple Variable Question
Hi everyone.... again,

I am really getting into php still. Learning more every day. I love it

Save User Inputs while javascript reloading!
hi..
i have written a PHP code in which i reload the page when user selects a value in dropdown..

Add code to enable passing of checkbox variable on login
Ok, I have a login page, but want to add a checkbox that when checked and successful login is made i

SAP Project Module
I have seen in the SAP Project Module,plan cost and budget are not equal and even difference is sign

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