Hi,
I'll just keep it short.
I have a script that checks the user password & username and matches them against the database, and if they are correct, it logges them in.
there is a script that's called auth.php and it's included in every file. It produces a variable $auth with a value of 0 or 1. if it's 1, then there's a members panel on a page. If it's 0, then they get a login form at the same place.
The problem is that after I logged in once, the script won't change to the login script, even after I've logged out. I don't know what's wrong, maybe something small.. Here's the script:
auth.php
if(!defined('IN_SERVER')) {
echo "<center>Restricted!</center>";
exit();
}
if(!isset($_SESSION['password']) || !isset($_SESSION['username'])) {
$auth = "0";
return;
} else {
$auth = "1";
if($_SESSION['name'] == NULL) {
$_SESSION['name'] = $_SESSION['username'];
}
}
quick_login.php
if(!defined('IN_SERVER')) {
echo "<center>Restricted!</center>";
exit();
}
if($auth = "0") {
?>
<div class="menu_top">
Quick Login
</div><br>
<form action="log_in.php" method="post">
<table class="login_table">
<tr>
<td valign="center" width="30%" align="left">Username:</td>
<td valign="center" width="70%" align="left">
<input type="text" name="username"></td>
</tr>
<tr>
<td valign="center" width="30%" align="left">Password:</td>
<td valign="center" width="70%" align="left">
<input type="password" name="password">
</td>
<tr>
<td width="30%" align="right">
<a href="register.php">Register</a></td>
<td width="70%" valign="center" align="center">
<input type="submit" value="Login" class="button">
</td></tr></table>
</form>
</td>
<?php
} else if($auth = "1") {
?>
<div class="menu_top">
Members Panel
</div><br>
<div class="members_div" valign="top">
Welcome, <u><?php print $_SESSION['name']; ?></u>.<br>
You are a member since <u><?php print $_SESSION['regdate']; ?></u>.<br><br>
<a href="./members/edit_profile.php">Edit Profile</a><br>
<a href="./members/post_content.php">Post Content</a><br>
<a href="./members/logout.php">Logout</a><br>
<?php
}
?>
logout.php
if(!session_is_registered('username')) {
?>
<td class="main_cell" valign="top">
You haven't been logged in yet!!<br><br>
<form action="log_in.php" method="post">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
<input type="submit" value="login"> <input type="reset" value="reset">
</form>
</td>
<?php
} else {
unset($_SESSION['username']);
unset($_SESSION['password']);
session_destroy();
}
Anyone please help!!