View Full Version : Showing Admin Links

07-16-2007, 10:45 AM
Hi the following is my login code, when you login it shows links instead of the login box, and when you logout the login box shows instead of the links.

If i were to be a certain user then extra links will show.

The problem is, is that the links show for the certain user but when you logout they still show, How would i be able to make it so the extra links appear for a certain user and dissapear when they log out???

if(@$_SESSION['Loggedin'] == 'true'){



}else {
@$_SESSION['Loggedin'] = 'false';
$_SESSION['admin'] = 'false';

if ($_SESSION['incorrect_login'] =='true')
{echo"Incorrect username or password";}

<form action="user_logged_in.php" method="post">

Username:<br> <input type="text" name="loginname" size="19"><br>
Password: <br><input type="password" name="password" size="19"><br>
<br><input type="Submit" value="Login">

<span class="main_class">
<a href="register.php">Register</a><br>
<a href="link">Forgot Password?</a><br>

<?php } ?>



if (@$_SESSION['loginname'] == 'USERNAME HERE'){
$_SESSION['admin'] = 'true';}
else{$_SESSION['admin'] = 'false';}

if ($_SESSION['admin'] == 'true'){ ?>


<?php ;} ?>

My Logout code:

<?php session_start();

$_SESSION['Loggedin'] = 'false';

$_SESSION['admin'] = 'false';



07-16-2007, 10:54 AM
when you log out you set loggedin and admin to false, however your script sets 'admin' status based on whether the username is set to a given value, so if I log in as an admin, then logout, my admin status is set to false. But the script checks to see if my username is an admin - it resets the admin status to true.

Unless you're keeping data in the session that doesnt require users to be logged in. Use session_destroy() (http://www.php.net/manual/en/function.session-destroy.php) to logout users

07-16-2007, 12:10 PM
Hey thanks for that, it worked!!!!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum