My system seem to be working fine and i followed the tutorial all the way through! But whenever there is a "session_start" on a page I get this warning when I test the page using wamp 5. The page shows as I want but there is a warning at the top.
Can Anyone help?
Login.php
Here is the warning produced on the login.php page
"Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\wamp\www\K2F1\Pages\login.php:6) in C:\Program Files\wamp\www\K2F1\Pages\login.php on line 485
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\wamp\www\K2F1\Pages\login.php:6) in C:\Program Files\wamp\www\K2F1\Pages\login.php on line 485"
Here's the code
Code:
<table width="555" height="300" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<?php
session_start();
include 'config.php';
if(isset($_POST['login']))
{
$username = trim(addslashes($_POST['username']));
$password = md5(trim($_POST['password']));
$query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error());
$row = mysql_fetch_array($query);
//now check see if they are activated
if(mysql_num_rows($query) > 0)
{
if($row['Activated'] > 0)
{
$_SESSION['s_logged_n'] = 'true';
$_SESSION['s_username'] = $username;
$_SESSION['s_name'] = $row['Name'];
header("Location: member.php");
} else {
echo'
<html>
<head>
<title>K2F1 - The Revolution Has Come - Member Login</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="error">
<p>Sorry, you must activate your K2F1 account before you can access the member area. Please check your email and try again. Don'."'".'t forget to check your email spam/junk folder.</p>
<p>Didn'."'".'t recieve your validation email? <a href="resend.php">Click here</a> to resend your validation email.</p>
</div>
</body>
</html>
';
}
} else {
echo'
<html>
<head>
<title>K2F1 - The Revolution Has Come - Member Login</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="error">
<p>Sorry, there was an error while processing your login. It appears that your Username and/or Password were incorrect. Please try again.</p>
<p>Didn'."'".'t recieve your validation email? <a href="resend.php">Click here</a> to resend your validation email.</p>
</div>
</body>
</html>
';
}
} else {
?>
<link href="style.css" rel="stylesheet" type="text/css">
<body>
<div id="wrapper">
<p><span class="style6">K2F1 Member Login</span><br>
<div id="main">
</p>
<p><strong>You must login to K2F1 to view this page. Enter your Username and Password and then click the login button.</strong></p>
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<p><span class="style12">Username:</span><br>
<input name="password" type="text" Cid="username">
<p><span class="style12">Password:</span><br>
<input name="password" type="password" id="password">
</p>
<p>
<input name="login" type="submit" id="submit" Value="Login">
</p>
</form>
<p><strong>Didn't recieve your validation email? <a href="resend.php" class="style8">Click here</a> to resend your validation email.</strong></p>
<p><strong>Need a K2F1 member account? <a href="register.php" class="style9">Click here</a> to register. <span class="style10">It's completely free!</span></strong></p>
<?php } mysql_close($l); ?>
</td>
</tr>
<tr>
<td height="1000"> </td>
</tr>
</table>