I'm trying the following code. A user logs in, his details passed on to this script. If ok, he gets sent back to main page after cookie has been created. Otherwise he gets an error message. The user authentication works fine, but I'm not getting any cookie created...
<? SetCookie ("customer",$user,time()+864000); ?>
<HEAD></HEAD>
<BODY>
<?
mysql_connect("localhost","username","password") or DIE("unable to connect to database");
mysql_select_db("dbname") or die("unable to select database");
$result = mysql_query("SELECT * FROM customer WHERE userid='$user' AND password='$password' ");
if ($row = mysql_numrows($result)) {
echo "<A href=http://www.site.com/menubar-test.php>Click Here!</A>";
}
else {
SetCookie("customer");
echo "
<HEAD>
<STYLE TYPE='text/css'>
<!--
@import url(http://www.site.com/css/css_index.css);
-->
</STYLE>
</HEAD>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<center>
<table width=40% cellpadding=1 cellspacing=0 bgcolor=#000000 border=0>
<tr><td>
<table style='background:rgb(219,217,217);' width=100% cellpadding=4 cellspacing=0 border=0>
<tr><td bgcolor=black align=center>
<font class=confirmerrortitle face=verdana,helvetica,arial size=2>Incorrect Login Details</font></td></tr>
<tr><td>
<font class=confirmerror face=verdana,helvetica,arial size=-2> The user ID or Password that you provided is incorrect. Please go back and select another.</font></td></tr>
<tr><td cellpadding=6 align=center>
<input class=bttn type=button name=goBack value='Go Back' onclick=history.back(1)>
</td></tr>
</table>
</td></tr>
</table>
</center>
";
exit; }
?>