I wonder if this question has been done to death, but I'm trying to do something whihch I think is really simple.
I want to display two images on a page, have two radio buttons with a submit button, once one of the options is selected and the submit button is click, I want to set a cookie with the value of the radio object (option 1 or option 2) and then send the user to another page confirming their choice.
If the user then tries to go to the choice page again, if the cookie is set, redirect them to the results page.
Here's my code so far, which does the majority of the functionality described, but I need the redirect if the cookie is set.
Firstly, is the best way to do it and secondly, I want the redirect if cookie is set.
Many thanks ...
I want to display two images on a page, have two radio buttons with a submit button, once one of the options is selected and the submit button is click, I want to set a cookie with the value of the radio object (option 1 or option 2) and then send the user to another page confirming their choice.
If the user then tries to go to the choice page again, if the cookie is set, redirect them to the results page.
Here's my code so far, which does the majority of the functionality described, but I need the redirect if the cookie is set.
Code:
<?php
$vote = $_POST['vote'];
$self = $_SERVER['PHP_SELF'];
if ($vote != null) {
setcookie( "userVote", $vote , time() + 604800 );
header( "Location:design_ok.php" );
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>New Website Design</title>
</head>
<body>
<span style="font-size:24px;">What's you choice?</span><br />
<table width="100%" border="1" cellpadding="3">
<tr>
<td align="center" bgcolor="#FFFFFF"><span class="style1">Option 1 </span></td>
<td align="center" bgcolor="#FFFFFF"><span class="style1">Option 2 </span></td>
</tr>
<tr>
<td align="center"><img src="design1_web.jpg" width="585" height="438" alt="Design 1" title="Design Option 1" /></td>
<td align="center"><img src="design2_web.jpg" width="582" height="437" alt="Design 2" /></td>
</tr>
<form id="voteForm" name="voteForm" action="<?php echo( $self ); ?>" method = "post">
<tr>
<td align="center" colspan="2">
<input type = "radio" name = "vote" value = "Option 1">Option 1
<input type = "radio" name = "vote" value = "Option 2">Option 2
<br />
<input type="submit" name="Submit" value=" Vote " />
</td>
</tr>
</form>
</table>
</body>
</html>
Firstly, is the best way to do it and secondly, I want the redirect if cookie is set.
Many thanks ...