Login box display question
Posted: Sat Mar 01, 2008 5:37 pm
I have created a relatively simple login system linked to a mysql database. The login part is working fine, but what i would like to know is how to hide the login box (and replace it with a welcome message for example) when the user is logged in. My system does use cookies if that helps at all,
However, this does not seem to work, the login box is never there, even after clearing all cookies :/
Thanks for any help,
Josh.
Code: Select all
//Checks if there is a login cookie
if(isset($_COOKIE['ID_my_site']))
//if there is, it logs you in and directes you to the members page
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
if ($pass != $info['password'])
{ ?>
<form action="login.php" method="post" STYLE="margin: 0px; padding: 0px;">
<input name="username" type="text" id="username" value="Username" onFocus="if (this.value==this.defaultValue) this.value='';" />
<input name="password" type="password" id="password" value="Password" onFocus="if (this.value==this.defaultValue) this.value='';"/><br>
<a href="members.php" title="Members Area" target="content">Members Area</a> | <a href="registration.php" title="Register" target="content">Register</a>
<input type="submit" id="login" name="login" value="Login" />
</form>
<? }
else
{
echo "Welcome";
}
}
} ?>
//html for rest of site down here
Thanks for any help,
Josh.