I am having a problem with both my Login and Registration codes creating the intended cookie and forwarding the login to the member page.
The Error:
Warning: Cannot modify header information - headers already sent by (output started at /home/tplrpgpc/public_html/login.php:64) in /home/tplrpgpc/public_html/login.php on line 93
Warning: Cannot modify header information - headers already sent by (output started at /home/tplrpgpc/public_html/login.php:64) in /home/tplrpgpc/public_html/login.php on line 96
This is the code that is causing the error:
setcookie("save_user", htmlentities($_POST['username']), $month);
$login = "INSERT INTO logins (account, ip, success) VALUES ('".mysql_real_escape_string($_POST['username'])."', '".$_SERVER["REMOTE_ADDR"]."', 'Yes')";
$add_login = mysql_query($login);
header("location: news.php");
The first line is the line 93 error and the ending line is line 96. This is the same code causing errors on both pages. It is not starting the cookie and is not redirecting to news.php. In my database it is showing up as the registration successful and the login complete but like I said is not starting the session and redirecting. Any help would be great.
Edit: I have just realized that it logs in the user but before doing so it shows the error and they have to reclick on the login link in order to go to the members page. I would like this to redirect instead.