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!
I am creating an admin panel for my site and I have came across some silly error that I just cannot seem to pass. What it is, is that I want only users with a level of 1 or 2 to access the panel otherwise the user is informed with an error message. The code that I cannot seem to pass go's like:
$sql = "SELECT * FROM members WHERE username = '".$_SESSION['username']."'";
$result = mysql_query($sql) or die("Error!");
if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
$level1 = $row['level'];
}
if ($level != '1' || $level != '2')
{
echo "You are not allowed to access this area of the site!<p>";
echo "Click <A href='http://www.site.com/index.php'>here</A> to go to the index page!";
exit;
}
?>
I was thinking perhaps an array with the numbers 1 and 2 but I am not too sure on how I would go about doing that. Any help appreciated!