Code: Select all
<?php
$cookies=FALSE;
----------------------------------------------------------------
//This is the section I am having trouble with
if (isset ($_POST['Submit'])) {
setcookie ('fontcolor', $_POST['fontcolor']);
setcookie ('bgcolor', $_POST['bgcolor']);
$cookies=TRUE;
}
?>
----------------------------------------------------------------
<head>
<title>Customize Your Settings</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if ($cookies) {
print '<p>Your settings have been entered! Click <a href="viewsettings.php">here</a> to go back to the main page.</p>';
}
?>
<form name="settings" method="post" action="customize.php">
Select your font color:<br>
<select name="fontcolor">
<option value="#0000FF">Blue</option>
<option value="#FF0000">Red</option>
<option value="#00FF00">Green</option>
<option value="#FFFF00">Yellow</option>
<option value="#FF8000">Orange</option>
<option value="#8000FF">Purple</option>
<option value="#000000">Black</option>
<option value="#FFFFFF">White</option>
<option value="#8080FF">Teal</option>
</select><br>
<p>Select your background color:<br>
<select name="bgcolor">
<option value="#0000FF">Blue</option>
<option value="#FF0000">Red</option>
<option value="#00FF00">Green</option>
<option value="#FFFF00">Yellow</option>
<option value="#FF8000">Orange</option>
<option value="#8000FF">Purple</option>
<option value="#000000">Black</option>
<option value="#FFFFFF">White</option>
<option value="#8080FF">Teal</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>I know that all the syntax is correct and that i named all the variables and cookies correctly, but for some reason php will only create the second cookie. I know that only the second cookie is created because even when i switch the places of the two cookies at the top the second one is the only one that is created. Will someone please help me with this, because i am really confused and have no idea what to do.
[Edit: Added PHP tags for eyecandy. --JAM]