i keep getting this error with a login script, does anyone know how to solve this?
Warning: Cannot send session cookie - headers already sent by (output started at C:\WINDOWS\Desktop\webserver\clphp\validate.php:6) in C:\WINDOWS\Desktop\webserver\clphp\validate.php on line 7
Warning: Cannot send session cache limiter - headers already sent (output started at C:\WINDOWS\Desktop\webserver\clphp\validate.php:6) in C:\WINDOWS\Desktop\webserver\clphp\validate.php on line 7
not valid
here goes the script
<?php
// next line is number seven
session_start();
$db_user = 'root';
$db_pass = 'root';
$user_name = $_POST['user_name'];
$password = $_POST['password'];
//connect to the DB and select the database
$connection = mysql_connect('localhost', $db_user, $db_pass) or die(mysql_error());
mysql_select_db('chungo', $connection) or die(mysql_error());
//set up the query
$query = "SELECT * FROM users1
WHERE user_name='$user_name' AND password='$password'";
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
//if there's exactly one result, the user is validated. Otherwise, he's invalid
if($affected_rows == 1) {
print 'validated';
//add the user to our session variables
$_SESSION['username'] = $user_name;
}
else {
print 'not valid';
}
?>
the error comes with the session_start()