I have the following code which I use in conjunction with a members script which displays a members username the page or asks guests to login or register.
PHP code:
if ($_SESSION['username'])
{
echo "".$_SESSION['username'].", you are logged in.<br><small><a href=\"logout.php\">Click here to logout</a></small>";
}
else
echo "Welcome Guest!<br><small><a href=\"login.php\">Login</a> or <a href=\"register.php\">Register</a></small>";
It works perfectly well, though now I want to modify it so if a user with admin privileges logs in it identifies the username and offers a link to the admin page.
So here's my modified code:
<? php
$validateadmin = $_SESSION['username'];
if ($validateadmin == "admin1" or $validateadmin == "admin2")
{
echo "Hello $validateadmin, you have <a href=\"admin.php\">admin</a> privileges.<br><small><a href=\"logout.php\">Click here to logout</a></small>";
}
else if ($_SESSION['username'])
{
echo "".$_SESSION['username'].", you are logged in.<br><small><a href=\"logout.php\">Click here to logout</a></small>";
}
else
{
echo "Welcome Guest!<br><small><a href=\"login.php\">Login</a> or <a href=\"register.php\">Register</a></small>";
}
?>
Any idea's what I'm doing wrong? It either leaves me with a blank page or errors. I know it's probably a newbie error but for the life of me I don't know what's wrong.