title: Setting User based preferences in PHP using Cookies
body: <p>I'm doing an assignment where I need to be able to change the color of ones log in page according to preference. Now I have been able to successfully do that BUT no matter what I do the color will not take up the whole page only around the FORM itself leaving the rest white, can you please tell me where I have made the mistake? Please see my coding below:</p>
  
  <pre><code>&lt;?php
  include('session.php');
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Your Home Page&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div id="profile"&gt;
  &lt;b id="welcome"&gt;Welcome : &lt;i&gt;&lt;?php echo $login_session; ?&gt;&lt;/i&gt;&lt;/b&gt;
  
  &lt;b id="logout"&gt;&lt;a href="logoff.php"&gt;Log Out&lt;/a&gt;&lt;/b&gt;
  
  &lt;?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";
      }
  ?&gt;
  
  
  
  
  &lt;form method='post' &lt;?php echo "STYLE='background-color:".$color.";'";?&gt; &gt;&lt;p id='txtorder'  &gt;color: &lt;/p&gt;
  
      &lt;select name='order' id='order'&gt;
          &lt;option value="red" &lt;?php echo $red; ?&gt; &gt;red&lt;/option&gt;
          &lt;option value="blue" &lt;?php echo $blue; ?&gt; &gt;blue&lt;/option&gt;
          &lt;option value="green" &lt;?php echo $green; ?&gt; &gt;green&lt;/option&gt;
          &lt;option value="gold" &lt;?php echo $gold; ?&gt; &gt;gold&lt;/option&gt;
          &lt;option value="silver" &lt;?php echo $silver; ?&gt; &gt;silver&lt;/option&gt;
          &lt;option value="purple" &lt;?php echo $purple; ?&gt; &gt;purple&lt;/option&gt;
      &lt;/select&gt;
      &lt;input type='submit' value='sort'/&gt;
  
  
  &lt;/form&gt;
   &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>