<?php
//showdata.php

if ($_SERVER['REQUEST_METHOD'] == 'GET') {
  echo
"GET data<br>\n";
  echo
"QUERY_STRING: ",$_SERVER['QUERY_STRING'],"\n";
  echo
"<p>\n";
  
display_array($_GET,'$_GET');
}
elseif (
$_SERVER['REQUEST_METHOD'] == 'POST') {
  echo
"POST data<br>\n";
  echo
"CONTENT_LENGTH: ",$_SERVER['CONTENT_LENGTH'],"<br>\n";
  
//readfile("php://stdin");   //empty???  how to get raw POST data?

  
echo "<hr>\n";
  
display_array($_POST,'$_POST');
}
     

else {
  echo
"it's neither GET nor POST. <br>\n";
  echo
$_SERVER['REQUEST_METHOD'];
}


echo
"<hr>\n";
display_array($_COOKIE,'$_COOKIE');

echo
"<hr>\n";
display_array($_SERVER,'$_SERVER');

echo
"<hr>\n";
display_array($_ENV,'$_ENV');

echo
"<hr>\n";
//display_array($_FILES['uploadFile'],'$_FILES');
display_array($_FILES,'$_FILES');
//must know name of file upload form element...
//<input type="file" size="30" maxlength="100"  name="uploadFile">

echo "<hr>\n";
display_array(apache_request_headers(), 'apache_request_headers()');


function
display_array($arr, $title) {
  echo
"<table border=1>\n";
  echo
"<caption>$title</caption>\n";
  
ksort($arr);
  
reset($arr);
  while (list(
$key,$value) = each($arr)) {
    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";
}



?>