Cookie Header Wrning???
Posted: Fri Feb 28, 2003 10:05 pm
Hi!
I have this code for a login script:
But it gives me an error like this:
Warning: Cannot send session cookie - headers already sent by (output started at c:\program files\easyphp\www\created\club\login.php:8) in c:\program files\easyphp\www\created\club\login.php on line 25
Warning: Cannot send session cache limiter - headers already sent (output started at c:\program files\easyphp\www\created\club\login.php:8) in c:\program files\easyphp\www\created\club\login.php on line 25
Why is that?
Thanks!
I have this code for a login script:
Code: Select all
<?php
// ======================================
// Logged in
// ======================================
if ($mode == "login") {
session_start();
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$query = "SELECT * FROM club_members WHERE username='$username' AND password='$password' AND level='1'";
$result = mysql_query($query) or die('error making query');
$affected_rows = mysql_num_rows($result);
if($affected_rows == 1) {
$array = mysql_fetch_array($result);
$email = $array[email];
$_SESSION['email'] = $email;
$_SESSION['name'] = $name;
echo "logged in!";
}
else {
session_destroy();
print ("Your Username or password is not correct, please login agian...");
}
}
// ======================================
// Logging in
// ======================================
else {
?>
<form action="login.php" method="post">
<input type="hidden" name="mode" value="login">
<table border="0" cellspacing="1" cellpadding="5" width="500" bgcolor="#999999">
<tr>
<td colspan="2" height="30" align="center" bgcolor="#ffffff"><b>Login</b></td>
</tr>
<tr>
<td bgcolor="#ffffff">Username:</td><td bgcolor="#ffffff"><input type="text" name="username" size="30"></td>
</tr>
<tr>
<td bgcolor="#ffffff">Password</td><td bgcolor="#ffffff"><input type="text" name="password" size="30"></td>
</tr>
<tr>
<td colspan="2" bgcolor="#ffffff" align="center"><input type="submit" value="Login!"></td>
</tr>
</table>
</form>
<?php
}
?>Warning: Cannot send session cookie - headers already sent by (output started at c:\program files\easyphp\www\created\club\login.php:8) in c:\program files\easyphp\www\created\club\login.php on line 25
Warning: Cannot send session cache limiter - headers already sent (output started at c:\program files\easyphp\www\created\club\login.php:8) in c:\program files\easyphp\www\created\club\login.php on line 25
Why is that?
Thanks!