我正在进行一项任务,我需要根据喜好更改登录页面的颜色。现在我已经能够成功地做到这一点,但无论我做什么,颜色都不会占用整个页面只围绕FORM本身留下其余的白色,你能告诉我我在哪里弄错了吗?请参阅下面的编码:
<?php
include('session.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Your Home Page</title>
</head>
<body>
<div id="profile">
<b id="welcome">Welcome : <i><?php echo $login_session; ?></i></b>
<b id="logout"><a href="logoff.php">Log Out</a></b>
<?php
$red = "";
$blue = "";
$green = "";
$gold = "";
$silver = "";
$purple = "";
$hour = time() + 3600;
if (isset($_POST['order']))
{
$color = $_POST['order'];
$$color = " selected";
setcookie("Free_cookies", $color, $hour);
}
else if(isset($_COOKIE['Free_cookies']))
{
$color = $_COOKIE['Free_cookies'];
$$color = " selected";
}
else
{
$color = "red";
$red = " selected";
}
$red = "";
$blue = "";
$green = "";
$gold = "";
$silver = "";
$purple = "";
$hour = time() + 3600;
// first check for a new value, and use it as well as saving it for next time
if (isset($_POST['order']))
{
$color = $_POST['order'];
$$color = " selected";
setcookie("Free_cookies", $color, $hour);
}
// if there's no new value, THEN check for a previous value in a cookie
else if(isset($_COOKIE['Free_cookies']))
{
$color = $_COOKIE['Free_cookies'];
$$color = " selected";
}
// otherwise default to red
else
{
$color = "red";
$red = " selected";
}
?>
<form method='post' <?php echo "STYLE='background-color:".$color.";'";?> ><p id='txtorder' >color: </p>
<select name='order' id='order'>
<option value="red" <?php echo $red; ?> >red</option>
<option value="blue" <?php echo $blue; ?> >blue</option>
<option value="green" <?php echo $green; ?> >green</option>
<option value="gold" <?php echo $gold; ?> >gold</option>
<option value="silver" <?php echo $silver; ?> >silver</option>
<option value="purple" <?php echo $purple; ?> >purple</option>
</select>
<input type='submit' value='sort'/>
</form>
</div>
</body>
</html>