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
Post a Comment