Please send questions to st10@humboldt.edu .
#!/usr/bin/perl -w

#######################################################
# lect10_06.pl
#
# all-in-one, now?
#    now with the help of CGI.pm?
# (and will fatal errors be passed on to browser,
#     and errors to the lect10_06_ref file?)
#
# by Sharon Tuttle 
#
# last modified: 11-02-04
#######################################################

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser warningsToBrowser carpout);

warningsToBrowser(1);  # activate warnings

BEGIN
{
   open REF, ">> lect10_06_ref"
      or die "Cannot open lect10_06_ref: $!";
   carpout(REF);
}

# PRINT a form for the user to react to

print header, "\n";

print start_html(-title=>'lect10_06 page'), "\n";

# there's a function h1 corresponding to the tag <h1>

print h1('lect10_06 page'), "\n",

      # start_form returns a form tag with method POST,
      #    with action the current script,
      #    and enctype the usual default
      start_form, "\n",

      br, br, "\n",
      "Your name: \n",
      textfield(-name=>'desired_label',
           -size=>30,
           -maxlength=>26,
           -value=>'appears in field initially'), "\n",

      br, br, "\n",
      "password: \n",
     
      password_field(-name=>'passwd_label',
                     -size=>20,
                     -maxlength=>10), "\n",

      br, br, "\n",

      checkbox(-name=>'checked1',
               -label=>'George',
               -value=>'george'), "\n",
      br, br, "\n",

      checkbox(-name=>'checked1',
               -label=>'Harold',
               -value=>'harold'), "\n",
      br, br, "\n",

      submit(-value=>'Send it'), "\n",

      endform, "\n";

print hr, "\n";

# remember: function param() returns a list containing the names
#    of all the parameters from the form
if (param())
{
    print REF "----------------------------------------------\n";
    print REF "\nHere are fields and their values:\n";
    foreach $parameter (param)
    {
        print REF "   $parameter => ", param($parameter), "\n";
    }

    # just to try to tell different "calls" printouts apart;
    print REF "\n";
    print REF "END **********************************************\n";

    close REF;

    # try to send back some confirmation html

    #print header, "\n";

    print h1("Confirmation"), "\n";

    print "<hr>\n";
    print "Information transferred?<br>";

    my @looky = param('checked1');
    foreach (@looky)
    {
        print br;
        print "A SEP VALUE: ", $_, "\n";
    }

    print br;
    print "name given was: ", param('desired_label'), "\n";
    print "value of checked1: ", "@looky", "\n";
}

print end_html, "\n";

# end of lect10_06.pl