Hi! I am having trouble in checking userlevel at the time of login. The pages set for admin level are not displayed if the user is not admin, but admin cant access the pages either!!:D Please solve my problem!
My code is:

<?php

if(!isset($_SESSION['userlevel']) || empty($_SESSION['userlevel']))
{
if ($_SESSION['userlevel'] == 2)
{
echo "ADMIN";
}
else
{
header('Location:index.php?query=notadmin');
}
}
?>

try this:

<?php

if(isset($_SESSION['userlevel']) || !empty($_SESSION['userlevel']))
{
if ($_SESSION['userlevel'] == 2)
{
echo "ADMIN";
}
else
{
header('Location:index.php?query=notadmin');
}
}
else
{
echo "session not exists..";
}
?>

You are right shanti.When I made the changes in code, I get message:

session not exists..

But it works fine with other levels.Dont know why its happening??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.