admin and user

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hrubos
Forum Contributor
Posts: 172
Joined: Sat Oct 07, 2006 3:44 pm

admin and user

Post by hrubos »

Plz , how to solve if when user login, system can realize he is an admin or an user???
User avatar
MrPotatoes
Forum Regular
Posts: 617
Joined: Wed May 24, 2006 6:42 am

Post by MrPotatoes »

access level or a permissions system and in the front forum. someone'll move it.

its gonna be in the code forum btw
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

moved to code
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

there are a lot of ways, depending on how many different levels of permissions you want, but if you just want admin or user permissions, you could set a column in your database or whatever you use to store username and password...

Code: Select all

<?php
if($posted['username'] == $datasource['username'] && $posted['password'] == $datasource['password'])
{
    $_SESSION['logged_in'] = true;
    $_SESSION['admin'] = false;
    if($datasource['admin'])
    {
        $_SESSION['admin'] = true;
    }
}
?>
hrubos
Forum Contributor
Posts: 172
Joined: Sat Oct 07, 2006 3:44 pm

Post by hrubos »

sorry, but I really ur how to run.

I have had table user, in which are user_name and password. SO I have to create new table for user_admin or what else to do?And I can use this code in my case now???
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

create a new field on that table that identifies the level of user they are.
Post Reply