Here is my code to the login page. My problem with it is that when the cookies are being set it gives me a white screen with the link to my index page. I want it to set the cookies and when it shows the link i want it to be shown in the original screen, not the white one. If you find the "Already Logged in" section, that is where i want the link to the home page and the error msg "bad username or password" to be displayed. I hope you understand. sorry if its too long.
<?php
if (isset($_POST['submit'])) {
extract($_POST);
$link = mysql_connect('localhost', 'root');
$db_select = mysql_select_db("bitphire");
$username = $_POST['username'];
$password = $_POST['password'];
$check_login = "SELECT username, password FROM members WHERE username = '$username' AND password ='$password'";
$result_login = mysql_query($check_login);
if ($result_login) {
$login_rows = mysql_num_rows($result_login);
if ($login_rows > 0) {
setcookie('username',$username,0,'/');
setcookie('password',$password,0,'/');
echo "<a href='index.php'>Home</a>";
} else {
echo "Bad username or password. Hit the back button and try again.<br>If you lost your password please visit the <a href='help.php'>help</a> page." . $user_array;
}
}
} else {
?>
<html>
<head>
<title>Bitphire.com</title>
</head>
<body bgcolor=#000000 alink="#235DDB" vlink="#235DDB" link="#235DDB">
<center><img src="./images/logo.jpg" width="720" height="175"></center>
<hr width="720" align="center">
<br>
<table border="1" bordercolor="#FFFFFF" width="100%">
<tr>
<td bgcolor="#2D0040" width="11%">
<table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#2D0040">
<h4><a href="index.php" style="text-decoration:none">.News</a></h4>
</td>
</tr>
<tr>
<td bgcolor="#2D0040">
<h4><a href="board/index.php" style="text-decoration:none">.Forums</a></h4>
</td>
</tr>
<tr>
<td bgcolor="#2D0040">
<h4><a href="cgi-bin/calendar.pl" style="text-decoration:none">.Calendar</a></h4>
<td>
</tr>
<tr>
<td bgcolor="#2D0040">
<h4><a href="contacts.php" style="text-decoration:none">.Contacts</a></h4>
</td>
</tr>
<tr>
<td bgcolor="#2D0040">
<h4><a href="help.php" style="text-decoration:none">.Help</a></h4>
</td>
</tr>
<tr>
<td bgcolor="#2D0040">
<h4><a href="members.php" style="text-decoration:none">.Members</a></h4>
</td>
</tr>
<tr>
<td bgcolor="#2D0040">
<h4><a href="login.php" style="text-decoration:none">.Login</a></h4>
</td>
</tr>
<tr>
<td bgcolor="#2D0040">
<h4><a href="register.php" style="text-decoration:none">.Register</a></h4>
</td>
</tr>
<tr>
<td>
 
</td>
</tr>
</table>
</td>
<td bgcolor="#3A0039" width="76%">
   
<center>
<table border="0" bgcolor="#2D0040" width="75%" cellspacing="8">
<?php
if (isset($_COOKIE['username']) && (isset($_COOKIE['password']))) {
echo "<tr><td align='center'><font color='#FFFFFF'>You are already logged in</font></td></tr>";
} else {
?>
<form action="<?php $PHP_SELF; ?>" method="post">
<tr>
<th colspan="2"><font color="#FFFFFF">Registered User's Login</font></th>
<th><font color="#FFFFFF">Description</font></th>
</tr>
<tr>
<td align="right"><font color="#FFFFFF">Username: </font></td>
<td><input type="text" maxlength="15" name="username"></td>
<td><font color="#FFFFFF">Enter your username.</font></td>
</tr>
<tr>
<td align="right"><font color="#FFFFFF">Password: </font></td>
<td><input type="password" name="password"></td>
<td><font color="#FFFFFF">Enter your password.</font></td>
</tr>
<td align="right"><font color="#FFFFFF"> </font></td>
<td><input type="submit" name="submit" value="Login"></td>
<td><font color="#FFFFFF"> </font></td>
</tr>
</form>
</table>
</center>
   
</td>
<td bgcolor="#2D0040" width="11%">
<table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>
<td><font color="#235DDB">
<center><h4>*Notes*</h4></center>
</font></td>
</tr>
<tr>
<td><font color="#235DDB">
<center><h4>-No Notes</h4></center>
</font></td>
</tr>
</table>
</td>
</tr>
</table>
<br><center>
<table border="0" bgcolor="#000000">
<tr>
<td><a href="index.php">.News</a> </td>
<td><a href="forums.php">.Forums</a> </td>
<td><a href="cgi-bin/calendar.pl">.Calendar</a> </td>
<td><a href="contacts.php">.Contacts</a> </td>
<td><a href="help.php">.Help</a> </td>
<td><a href="members.php">.Members</a> </td>
<td><a href="login.php">.Login</a> </td>
<td><a href="register.php">.Register</a> </td>
</tr>
<tr>
<td colspan="8"><h5><font color="#235DDB">If you see any errors, typo's, or dead links please E-Mail the <a href="mailto:webmaster@bitphire.com?subject=Error, Typo, Dead Link">webmaster</a>.</font></h5></td>
</tr></center>
</table>
</body>
</html>
<?php
}
}
?>