#!/usr/bin/perl

use strict;
use CGI;

my $key;
my $cgi;

$cgi = new CGI;

# print a standard HTTP header
print $cgi->header;

# print a standard HTML header
print $cgi->start_html(-title=>'A Simple Form Example'),
    $cgi->h1('A Simple Form Example'),
    "\n
\n"; # start the form # the statement shown defaults to POST method, and action equal to this script print $cgi->start_form; # print the form elements print "What's your name? ",$cgi->textfield(-name=>'name'), $cgi->p, "What's the combination?", $cgi->p, $cgi->checkbox_group(-name=>'words', -values=>['eenie','meenie','minie','moe'], -defaults=>['eenie','minie']), $cgi->p, "What's your favorite color? ", $cgi->popup_menu(-name=>'color', -values=>['red','green','blue','chartreuse']), $cgi->p, $cgi->submit(-name=>"Try me!"); # end of the form print $cgi->end_form, $cgi->hr; # IF this cgi was invoked because of a POST (i.e., the user hit the submit button), # show the values that were passed to it from the form if ($cgi->request_method() eq "POST" ) { print "Your name is ", $cgi->em($cgi->param('name')), $cgi->p, "The keywords are: ",$cgi->em(join(", ",$cgi->param('words'))), $cgi->p, "Your favorite color is ",$cgi->em($cgi->param('color')), $cgi->hr; } # finish up... print "
\n", $cgi->end_html;