I'm trying to have my script login and then set a cookie containing the user's id. everytime I do this, I get this error:
Warning: Cannot add header information - headers already sent by (output started at /www/ub.surfsolutions.com/echo/functions.php:696) in /www/ub.surfsolutions.com/echo/index.php on line 16
I know what causes this, I just don't know what is causing this in my script. Here is the beginning of my script, and I'm sure you'll see no headers are being sent before the cookie:
<?php
include("functions.php");
include("config.php");
dbConnect();
if (!isset($user_id)) {
if (!isset($username) || !isset($password)) {
$login = true;
}
}
if (isset($username) && isset($password)) {
$sql = mysql_array("SELECT password FROM members WHERE username='$username'");
if ($sql["password"] = $password) {
sess_start($sql["user_id"]);
setcookie("user_id", $sql["user_id"], time() + 1200);
See? Why does it keep giving me that error?