Login box display question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joshmills19
Forum Newbie
Posts: 1
Joined: Sat Mar 01, 2008 5:34 pm

Login box display question

Post by joshmills19 »

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,

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
 
 
However, this does not seem to work, the login box is never there, even after clearing all cookies :/




Thanks for any help,
Josh.
Post Reply