PHP access level system using session array -
i have login , register system working fine, although want add user access levels users admin access can go on page regular users can't. have code echoing know if work @ moment.
this code i'm using:
echo("hello $_session[user]"); if ($_session['user']==1) { echo "you have admin access"; } else { echo "you're regular user"; }
so basically, if user have level 1 in database, admin , below regular user.
the problem never works, displays "you're regular user"
and code:
echo("hello $_session[user]");
echo's out "hello arrayyou're regular user"
i know login system has session set user, says array.
here login page, didn't make since i'm new php: http://pastebin.com/h0zqnnse
and curious, know level row in database working because have echoed out fine using script, can see here
$_session['user']
associative array, containing various attributes of user retrieved database. id number in id
element of array, need do:
echo("hello {$_session['user']['username']} (id = {$_session['user']['id']})"); if ($_session['user']['id']==1) { echo "you have admin access"; } else { echo "you're regular user"; }
Comments
Post a Comment