<?php
if ($_SERVER['REQUEST_METHOD'] == 'GET')
  
header("Set-Cookie: icecream=yumyum;");
?>

<html>
<head>
<title>Ice Cream Survey</title>
</head>
<body>

<?php
//initial GET, display "static" page
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
?>

<form action="<?php $PHP_SELF; ?>" method="post" enctype="multipart/form-data">

text field<br>
<input name="username" size="30" type="text">

<p>
text field of maxlength<br>
<input name="age" size="2" maxlength="2" type="text">

<p>
password field<br>
<input name="password" size="20" type="password">

<p>
set of radio buttons.  one pre-selected with checked<br>
<input name="freq" value="hourly" type="radio" checked>Hourly<br>
<input name="freq" value="daily" type="radio">Daily<br>
<input name="freq" value="weekly" type="radio">Weekly<br>
<input name="freq" value="fortnightly" type="radio">Fortnightly<br>
<input name="freq" value="monthly" type="radio">Monthly<br>
<input name="freq" value="yearly" type="radio">Yearly<br>
<input name="freq" value="never" type="radio">Never<br>



<p>
checkboxes. two checked. [] for php<br>
<input name="emporia[]" value="Baskin-Robbins" type="checkbox" checked>Baskin-Robbins<br>
<input name="emporia[]" value="Blue Seal" type="checkbox" checked>Blue Seal<br>
<input name="emporia[]" value="Dairy Queen" type="checkbox">Dairy Queen<br>
<input name="emporia[]" value="A&amp;W" type="checkbox">A&amp;W<br>


<p>
select drop-down <br>
<select name="vote">
<option>Vanilla</option>
<option>Strawberry</option>
<option>Chocolate</option>
<option>Wasabi Goya</option>
<option>Other</option>
</select>

<p>
select with multiples and selected.  [] for php<br>
<select name="mags[]" multiple>
<option selected="selected">Ice Cream Today</option>
<option>Ice Cream Internationale</option>
<option selected="selected">Weight Watchers</option>
<option>Ice Cream Guide</option>
</select>

<p>
textarea<br>
<textarea name="poem" rows="6" cols="60">here is some default text already in
the textarea
</textarea>

<p>
file upload<br>
<input type="file" size="30" maxlength="100"  name="uploadFile">

<p>
<input value="Submit the survey" type="submit">

<br>
<input value="Clear your choices" type="reset">

<br>
<input value="This is a button button" type="button">

<p>
hidden field.  (view the source to see it)<br>
<input name="myhiddenfield" value="something meaningful in app" type="hidden">

</form>



<?php
######################################################################
//form has been posted to this php page
} else
include
'showdata.php';

/*
if ($_SERVER['REQUEST_METHOD'] == 'POST') {

  echo "Thanks for doing the survey.  Your submitted data:\n";


  echo "<p><table border=1>\n";
  echo "<tr><th>key</th><th>value</th></tr>\n";
  reset($_POST);
  //foreach ($_POST as $key => $value)
  while (list($key,$value) = each($_POST)) {
    if (is_array($value))     //multiple select or checkboxes
      $value = join(" ",$value);   //change from array to string
    echo "<tr><td>$key<td>$value</tr>\n";
  }
  echo "</table>\n";
  echo "<p>CONTENT_LENGTH: ",$_SERVER['CONTENT_LENGTH'],"\n";
}
*/
?>

</body>
</html>