I am using the setcookie function. However, how can you connect to the database, verify username and password. Then, set the cookie if all is well. You cannot setcookie after all of the code????
Calls to the setcookie() function must be done prior to any output to the client - any html or whitespace http://uk.php.net/setcookie.
You can avoid 'headers already sent' errors by outputting to the buffer prior to setting a cookie and then releasing output from the buffer to the client. http://uk.php.net/manual/en/outcontrol.examples.php
Difficult to tell the problem as you dont detail your script.
<?php
$cookie1=$_POST[cookie1];
$cookie2=$_POST[cookie2];
$self=$_SERVER['PHP_SELF'];
$referer=$_SERVER['HTTP_REFERER'];
require('connecttothedb.inc.php');
$sql="SELECT * FROM xxx where cookie2=\"$cookie2\" and cookie1=\"$cookie1\" ";
$result = mysql_query($sql,$connection) or die("Couldn't connect to members database at this time from xxx. Sorry for the inconvenience. Please try again later.<br>To inform us of the problem, please send us an email to: <a href='mailto:email'>email'</a>");
$num=mysql_numrows($result);
if($num!=0){setcookie("cookie1",$cookie1,time()+36000);
setcookie("cookie2",$cookie2,time()+36000);
setcookie("auth","ok");
$msg="<b>Welcome</b>";}
else
{echo ("You have an incorrect username or password.<br><br><a href='url'>Go Back To Login Page</a>");
exit();}
?>
Thanks,
Matt
__________________
Matt
webmaster of Please login or register to view this content. Registration is FREE - Online wedding planning