I am practicing with cookies and have created a page that will allow a user to specify a background color and text color. Upon submitting the page it should reload the same page with the new specifications. However, instead the page reloads and I get the same background and text colors as before, UNLESS I hit refresh OR open the page in a new new browser window. Is there anyway to fix this? Here is my code and everything seems to function correctly.
<?php
if ($been_submitted) {
setcookie("bg_color", "$new_bg_color", time()+ "10000000", "", "");
setcookie("text_color", "$new_text_color", time()+ "10000000", "", "");
} else {
if (!$bg_color) {
$bg_color = "white";
}
if (!$text_color) {
$text_color = "black";
}
}
?>
<html>
<head>
<title>User Customization</title>
</head>
<?php
echo ("<body bgcolor=$bg_color text=$text_color>\n");
?>
Currently your page looks like this!<br>
<form action="cookies.php" method="post">
Select a new background color:<br>
<select name="new_bg_color">
<option value=white>White</option>
<option value=black>Black</option>
<option value=blue>Blue</option>
<option vlaue=red>Red</option>
<option value=green>Green</option>
</select><p>
Select a new text color!<br>
<select name="new_text_color">
<option value=white>White</option>
<option value=black>Black</option>
<option value=blue>Blue</option>
<option value=red>Red</option>
<option value=green>Green</option>
</select><p>
<input type=hidden name=been_submitted value=true>
<input type=submit value=Submit name=submit>
</form>
</body>
</html>