I have this script that allows the user to select their favorite colors for the background color, the link color, the link hover color and the header color for the site while they are viewing it. Their selection is stored in the appropriately named cookies. After the user chooses the colors, it is supposed to change the color styles in file3.php, but i get a white page with black text. I can’t find the problem, and am really confused.
file1.php
<?php
//Handle the form if it has been submitted:
if (isset($_POST['background_color'], $_POST['link_color'], $_POST['link_hover_color'],
$_POST['header_color'])){
//send the cookies:
setcookie('background_color', $_POST['background_color'], time()+10000000);
setcookie('link_color', $_POST['link_color'], time()+10000000);
setcookie('link_hover_color', $_POST['link_hover_color'], time()+10000000);
setcookie('header_color', $_POST['header_color'], time()+10000000);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>File1</title>
<style type="text/css">
<!-- These are the styles the session (if it exists) should configure -->
a:link {color:blue;}
a:hover {color:orange;}
body {background-color:red}
h1 {color:blue; text-align:center;}
</style>
</head>
<body>
<?php
//if the cookies were sent print a message
?>
<div><p>Please complete this form to configure the appearance of this website:</p>
<form action="file2.php" method="post">
<select name="background_color">
<option value="">Background Color</option>
<option value="FF6600">Orange</option>
<option value="CC00CC">Purple</option>
<option value="FFFF00">Yellow</option>
<option value="00FF00">Green</option>
<option value="FF0066">Pink</option>
<option value="000099">Blue</option>
</select>
<select name="link_color">
<option value="">Link Color</option>
<option value="FF6600">Orange</option>
<option value="CC00CC">Purple</option>
<option value="FFFF00">Yellow</option>
<option value="00FF00">Green</option>
<option value="FF0066">Pink</option>
<option value="000099">Blue</option>
</select>
<select name="link_hover_color">
<option value="">Link Hover Color</option>
<option value="FF6600">Orange</option>
<option value="CC00CC">Purple</option>
<option value="FFFF00">Yellow</option>
<option value="00FF00">Green</option>
<option value="FF0066">Pink</option>
<option value="000099">Blue</option>
</select>
<select name="header_color">
<option value="">Header Color</option>
<option value="FF6600">Orange</option>
<option value="CC00CC">Purple</option>
<option value="FFFF00">Yellow</option>
<option value="00FF00">Green</option>
<option value="FF0066">Pink</option>
<option value="000099">Blue</option>
</select>
<input type="submit" name="submit" value="Configure!" />
</form>
</div>
</body>
</html>
file2.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>File2</title>
</head>
<body>
<div>
<?php
include('file1.php');
$backgroundcolor = $_POST['background_color'];
$headercolor = $_POST['header_color'];
$linkcolor = $_POST['link_color'];
$linkhovercolor = $_POST['link_hover_color'];
?>
<a href="file3.php">Click here to see it in action</a>
<br /><br />
</div>
</body>
</html>
file3.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>File3</title>
<?php
$backgroundcolor = $_COOKIE["background_color"];
$linkcolor = $_COOKIE["link_color"]; // Define the variable
$linkhovercolor = $_COOKIE["link_hover_color"];
$headercolor = $_COOKIE["header_color"];
?>
<style type="text/css">
<!-- These are the styles the session should configure -->
a:link {color:#<?php $linkcolor; ?>}
a:hover {color:#<?php $linkhovercolor; ?>}
body {background-color:#<?php $backgroudcolor; ?>}
h1 {color:#<?php $headercolor; ?> text-align:center;}
</style>
</head>
<body>
<div>
<h1>Welcome to YOUR pretty website</h1>
<a href = "File1.php">Click here</a> to go back and start over!</a>
</div>
</body>
</html>