I'm trying to set a cookie with a form so that a user doesn't have to see the form if they've already filled it out. It's a simple form that just gathers their name and email address and then redirects them to another page. I inserted the following script at the top of the HTML code:
The result is that the page redirect happens even if it's the first time hitting the page. Its as if, the "header" command is being executed regardless of the "if" condition. Shouldn't it be checking to see if a cookie is set, then setting one, if not?
I've also tried to just set a cookie
And no cookie is set.
I'm not a coder, just trying to figure this out on my own. If I need a php pro for this, I'll pay, but it seems simple enough for a novice to accomplish. Can anyone help?
<?php
if (!isset($_COOKIE['emailaddress'])) {
header( "Location: http://www.treasurecycler.com/nwga/index.php?option=com_phocadownload&view=sections&Itemid=78" );
}
else {setcookie ("emailaddress", "set")}
?>
The result is that the page redirect happens even if it's the first time hitting the page. Its as if, the "header" command is being executed regardless of the "if" condition. Shouldn't it be checking to see if a cookie is set, then setting one, if not?
I've also tried to just set a cookie
<?php
setcookie ("emailaddress", "set")
?>
And no cookie is set.
I'm not a coder, just trying to figure this out on my own. If I need a php pro for this, I'll pay, but it seems simple enough for a novice to accomplish. Can anyone help?