php - user access control getting user level -


i have login form <form method="post" action="formdata.php">
in formdata.php have variables as
$n=$_post['name']; $p=$_post['password'];

then after succesful login direct page "main.php".

from main.php want check user level , based on user level restrict pages user can access.

to user level included

$query=mysql_query("select level member  username='$n'"); $level=mysql_fetch_array($query); if ($level==3){ echo "level 3 user";     } 

but don't think user level database variable $level correctly doesn't executes if ($level==3).

can't use $n in where username='$n' because $n declared in formdata.php ?

how can level field value database?

your usage wrong. must

if($level[0] == 3)  

or

if($level['level'] == 3)  

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -