#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
use Data::Dumper;

# The following variables are set for security and performance.
# If you forget to set these parameters it won't hurt anything,
# but pray that no hacker tries posting a book to your script.
$CGI::POST_MAX = 1024 * 100; # max 100k posts
$CGI::DISABLE_UPLOADS = 1;

print header('text/html');

print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <title>Form Data Dump</title>
  <LINK rel="StyleSheet" type="text/css" href="../../style.css">
</head>
<body>
<h3>Form Data Dump</h3>
<p>
This program is designed to demonstrate the data structures Perl will read
from HTML forms. Just fill out some values, then click submit to see what the
resulting data structure will be. If you want more information about HTML forms,
see <a href="http://www.w3.org/TR/html4/interact/forms.html">the standard</a>.
For more information about the CGI Perl module, see <a
href="http://search.cpan.org/~lds/CGI.pm-3.20/CGI.pm">CPAN</a>.
</p>
<p>
The source code for this web application can be downloaded <a
href="/form_data_dumper.tgz">here</a>.
</p>
<p>
<form action="'.url().'" method="post">
<input type="radio" name="RadioButton" value="RadioButton1"> Here\'s Radio
Button 1
<br>
<input type="radio" name="RadioButton" value="RadioButton2"> Here\'s Radio
Button 2
<br>
<input type="checkbox" name="CheckBox"> A Check Box
<br>
<input type="text" name="Text"> Text
<br>
<input type="password" name="Password"> Password
<br>
<input type="hidden" name="HiddenValues" value="HiddenInputData">(There is a
hidden input element here containing a string).
<center>
<input type="submit"><input type="reset">
</center>
</form>
</p>
';
if (param())
{
  print '<p>
The parameters sent to this script (by you) are
deliberately being shown in a hash. Ordinary, one would simply open a
parameter by calling "param(\'name_of_parameter\')".
</p>
<p><textarea cols="80" rows="10">
';
  if (param())
  {
    my $query = new CGI;
    my $params = $query->Vars;
    print Dumper($params);
  }
  print '</textarea>
</p>
';
}

print '<i>
<p align="center"><a href="mailto:&#98;&#101;&#111;&#119;&#117;&#108;&#102;&#64;&#119;&#106;&#104;&#111;&#108;&#100;&#101;&#110;&#46;&#99;&#111;&#109;&#10;">W. John Holden</a>
<br>
Last updated May 6, 2006.</p>
</i>
</body>
</head>
';
