Ok so I recently learned php, and I am kinda getting used to it and it seems pretty nice. So I recently decided to add on a forum to my website, but the problem is that as soon as user logs in and my thing verifies that user exists i want to use session start, as soon as I do that I get this error
Warning: session_start() [
function.session-start]: Cannot send session cookie - headers already sent by (output started at public_html/forum/verification.php:9) in
public_html/forum/verification.php on line
56
And right after it this one
Warning: session_start() [
function.session-start]: Cannot send session cache limiter - headers already sent (output started at public_html/forum/verification.php:9) in
public_html/forum/verification.php on line
56
And then as soon as user logs in and the verification says he exists I want to redirect him to the forum page but I get this error
Warning: Cannot modify header information - headers already sent by (output started at public_html/forum/verification.php:9) in
public_html/forum/verification.php on line
58
I have no idea what is wrong and tried many things, can someone please help me out and explain what I do wrong here?
This is the code by the way
$result = mysql_query($SQL);
if($result)
{
$num_rows = mysql_num_rows($result);
if($num_rows>0)
{
if ($num_rows == 1)
{
$errorMessage = "Logged on";
session_start();
$_SESSION['login'] = "1";
header ("Location: page1.php");
}
else
{
$errorMessage = "There are multiple users with same name";
}
}
else
{
$errorMessage = "Invalid logon";
session_start();
$_SESSION['login'] = '';
}
}
else
{
$errorMessage = "Error logging on";
}
Thanks a lot in advance to whoever helps me