My question is, how can I set cookies in the middle of a script. I want to do a login script, and this doesn't appear to be working:
It just keeps saying that the header information has already been sent and that it can't modify it.
I am so confused,
-Nick

| Code: |
| if($remember == 'y')
{ $expire = time()+60*60*24*30; } else { $expire = 0; } //open database connection $connection = mysql_connect($host, $user, $pass) or die('Unable to Connect! Please try again later!'); //select database mysql_select_db($db) or die('Unable to select database! Please try again!'); //generate and excute query $randomString = randomString(16); $query = "SELECT * FROM marketplace_users WHERE user_name = '$username' AND user_pass = '$password'"; $result = mysql_query($query) or die("Error in Query: $query. " . mysql_error()); if(mysql_num_rows($result) > 0) { setcookie("LoginInfo",$username,$expire,"/",".marketplace.tsljournal.com"); //print results echo '<div align="center">Login Successful!<br>'; echo '<a href="index.php">Click here to go back!</a>'; echo '<script language="javascript" src="js/timerbar.js"></script></div>'; } else { echo '<div align="center">Login Unsucessful...<br>'; echo '<a href="login.php">Click here to go back!</a>'; echo '</div>'; } mysql_close($connection); |
It just keeps saying that the header information has already been sent and that it can't modify it.
I am so confused,
-Nick
