Please keep in mind that this is my first attempt at php and I am probably waaaayyy off. :-)
I am trying to check for the presence of a cookie that would have been made during someone’s last visit to my site. If the cookie is there, then I want to forward them to a URL included in a Querystring called "url"… otherwise I want to have them fill out a form and then send them off.
Once the form is processed, a cookie will be created so they dont have to see the form again. I am using: <? setcookie('MyCookie', 'yes', time()+(606024*60)); ?>
If there is no cookie present, I keep getting Undefined variable errors. If there is a cookie, the redirect seems to work fine.
Can you please take a look at it and tell me what I am doing wrong.
Thanks in advance.
<?
if($MyCookie != "yes") { //if no cooking, show form
echo "
<head>
<title>Submit Form</title>
</head>
<body bgcolor=\"#FFFFFF\">
<form NAME=\"Form\" METHOD=\"post\" ACTION=\"xing.php?url=$url\">
<table width=\"228\" cellspacing=\"1\" cellpadding=\"1\">
<tr>
<td width=\"76\">Name</td>
<td width=\"141\">
<input type=\"text\" name=\"name\">
</td>
</tr>
<tr>
<td width=\"76\">Email</td>
<td width=\"141\">
<input type=\"text\" name=\"email\">
</td>
</tr>
<tr>
<td width=\"76\">Phone</td>
<td width=\"141\">
<input type=\"text\" name=\"phone\">
</td>
</tr>
<tr>
<td width=\"76\">Company</td>
<td width=\"141\">
<input type=\"text\" name=\"company\">
</td>
</tr>
</table>
<table width=\"228\" cellspacing=\"1\" cellpadding=\"1\">
</table>
<p>
<input type=\"submit\" name=\"Submit\" value=\"Submit\">
<br>
</p>
</form>
</body>
";
} //end no cookie option
else { //if there is a cooking, send them on their way
echo"
<head>
<meta http-equiv=\"refresh\" content=\"1 ;URL=$url\">
</head>
";
}
?>