By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

admin user permission

P: 3
hi
i am new to php and mysql i am devloping a site wich required diffrent user level in admin area, basically i want to assign diffrent role for diffrent user like some user can update the records, some user can delete the record and superadmin will have all the access and could create the user too.

i search the google and found some basic idea however its not yet clear how to use user group and user permissions database, will you plz help me out i am using php and mysql i appriciate if some one explain me from the beginning

thanks
Dec 29 '07 #1
Share this Question
Share on Google+
3 Replies


100+
P: 137
Hee motif,
I did almost the same with my website.
I created an table admin with ID, username, password, email, admin.
Where admin is like 1, 2, and 3.
Then is set the session variables like:

[PHP]$query = mysql_query "SELECT * FROM admin WHERE username='user' AND password='password' LIMIT 1";

$admin = mysql_fetch_array($query);
session_start();
//set session variables
$_session['user'] = $admin['username'];
$_session['password'] = $admin['password'];
$_session['admin'] = $admin['admin'];
[/PHP]

Then you can do some compares in your script like:
[PHP]
if ($_session['admin'] == 2){
//blalblalbla
}else{
//bliebliebliep
}[/PHP]

Maybe this will help you.

Gr Paul
Dec 31 '07 #2

P: 3
thank you very much for your advices but i still have some confusion what u mean by following

"" Then you can do some compares in your script like:
[PHP]
if ($session['admin'] == 2){
//blalblalbla
}else{
//bliebliebliep
}[/PHP]

""

do i need to check condition on every page and every role(admin)?? if
if ($session['admin'] == 2){
//show edit button
}else{
//view button
}[/PHP]

so other idea trick can also work??

regards
Dec 31 '07 #3

Markus
Expert 5K+
P: 6,050
thank you very much for your advices but i still have some confusion what u mean by following

"" Then you can do some compares in your script like:
[PHP]
if ($session['admin'] == 2){
//blalblalbla
}else{
//bliebliebliep
}[/PHP]

""

do i need to check condition on every page and every role(admin)?? if
if ($session['admin'] == 2){
//show edit button
}else{
//view button
}[/PHP]

so other idea trick can also work??

regards
do i need to check condition on every page and every role(admin)??
Yes. It's simple - just do it on all pages that you need to check for.
Dec 31 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.