Grr. I have that problem AGAIN.
I really have no idea what the problem is :|, I don't know how to explain so here's my code:
<?php
include("config.php");
$eUsername = $_POST['username'];
$ePassword = $_POST['password'];
$con = mysql_connect("localhost","MY_USERNAME","MY_PASSWORD");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("forum", $con);
$result = mysql_query("SELECT * FROM members WHERE username = '$eUsername'");
while($row = mysql_fetch_array($result))
{
if ($ePassword==$row['password']) {
echo "Correct";
setcookie("loggedIn", "true", time()+1000000000);
setcookie("logUsername", "$eUsername", time()+100000000);
setcookie("logPassword", "$ePassword", time()+100000000);
}
else {
echo "Incorrect username/password. Please try again.";
}
}
mysql_close($con);
if ($_COOKIE['loggedIn']=="true") {
$curURL=basename($_SERVER['SCRIPT_NAME']);
echo "You are already logged in. <a href='$curURL?lo=true'>Log out?</a>";
}
echo "<br /><br />";
print_r($_COOKIE);
?>
So basically what this does is if you log in with the correct information, it will set three cookies, your username, password and one to check for the other two.
But when I do log in successfully, I get these errors:
Warning: Cannot modify header information - headers already sent by (output started at /home/scott/web/forum/index.php:18) in /home/scott/web/forum/index.php on line 19
Warning: Cannot modify header information - headers already sent by (output started at /home/scott/web/forum/index.php:18) in /home/scott/web/forum/index.php on line 20
Warning: Cannot modify header information - headers already sent by (output started at /home/scott/web/forum/index.php:18) in /home/scott/web/forum/index.php on line 21
:(
Somebody please help, thank you!! :)
-Scott