<?php
$type_sel = $_POST['type_sel'];
$size_sel = $_POST['size_sel'];
if ($type_sel)
      setcookie ("fonttype", $type_sel, time()+3600);
if ($size_sel)
     setcookie ("fontsize", $size_sel, time()+3600);
$fonttype = @$_COOKIE['fonttype'];
$fontsize = @$_COOKIE['fontsize'];
$type = array("arial", "helvetica", "sans-serif", "courier");
$size = array("1","2","3","4","5","6","7");
echo "<html><head><title>Cookie Test</title></head><body><div align = 'center'>";
echo "<form method = post>";
    echo "<b>What font type would you like to use? ";
    echo "<select name='type_sel'>";
    echo "<option selected value=''>default</option>";
    foreach ($type as $var) echo "<option>$var</option>";
    echo "</select><br><br>";
    echo "What font size would you like to use? ";
    echo "<select name='size_sel'>";
    echo "<option selected value=''>default</option>";
    foreach ($size as $var) echo "<option>$var</option>";
    echo "</select><br><br>";
    echo "<input type=submit>"; 
echo "</form>";
echo "<br><b>Your cookies say:</b><br>";
echo "<font ";
  if ($fonttype) echo "face=$fonttype ";
  if ($fontsize) echo "size=$fontsize ";
  echo ">";
  echo "\$fonttype = $fonttype<br>";
  echo "\$fontsize = $fontsize<br>";
  echo "</font><br>";
  echo "<b>Your form variables say:</b><br>";
  echo "<font ";
  if ($type_sel) echo "face=$type_sel ";
  if ($size_sel) echo "size=$size_sel ";
  echo ">";
  echo "\$type_sel = $type_sel<br>";
  echo "\$size_sel = $size_sel<br>";
  echo "</font>";
  echo "</div></body></html>";
?>
