Please send questions to
st10@humboldt.edu .
#!/usr/bin/perl -w
#######################################################
# lect10_04.pl
#
# will this save the info from the form on lect10_04.html,
# now with the help of CGI.pm?
#
# by Sharon Tuttle
#
# last modified: 11-02-04
#######################################################
#1
use CGI qw(:standard);
open HTML_INFO, ">> lect10_04_sent_info"
or die "Cannot open lect10_04_sent_info: $!";
#2
# no longer necessary...!
# if I'd like to write the information from the HTML form into
# a file, I can do it more easily...
#
# # first: get the information from the HTML form as one big string:
#
# read STDIN, $info_string, $ENV{"CONTENT_LENGTH"};
#
# # try to save it to lect09_04_sent_info:
#
# print HTML_INFO "-----------------------------------------------\n";
# print HTML_INFO "$info_string\n";
#
# # now let's slice'n'dice it, and see how it turns out:
#
# # first, change each = to & ? (want to be split into separate values,
# # I think)
#
# $info_string =~ s/=/&/g;
#
# # ...and change each + back to a blank now --- they won't be
# # accidentally split on now, with the &'s in place;
#
# $info_string =~ s/\+/ /g;
#
# print HTML_INFO "$info_string\n";
#
# # split on &
#
# @fields_and_values = split /&/, $info_string;
#
# print HTML_INFO "@fields_and_values\n";
#
# # store fields and their values into hash
#
# %field_value_hash = @fields_and_values;
#
# @ck = %field_value_hash;
# print HTML_INFO "@ck\n";
#
# print HTML_INFO "\nHere are fields and their values:\n";
#
# foreach $field (sort keys %field_value_hash)
# {
# print HTML_INFO "$field => $field_value_hash{$field}\n";
# }
# remember: function param() returns a list containing the names
# of all the parameters from the form
print HTML_INFO "----------------------------------------------\n";
print HTML_INFO "\nHere are fields and their values:\n";
foreach $parameter (param)
{
print HTML_INFO " $parameter => ", param($parameter), "\n";
}
#3
# I don't think it is really necessary to store these
# into a hash now, either (although I certainly could,
# if I wished...! or into a DBM file, or whatever.)
close HTML_INFO;
# try to send back a confirmation page
#4
# print "Content-type: text/html", "\n\n";
print header, "\n";
#5
# print "<html>\n";
# print "<head><title>Confirmation</title></head>\n";
# print "<body><h1>Confirmation</h1>\n";
print start_html(-title=>'Confirmation'), "\n";
print "<h1>Confirmation</h1>\n";
print "<hr>\n";
print "Information transferred?<br>";
#6
# print "name given was: ", $field_value_hash{"desired_label"}, "\n";
print "name given was: ", param('desired_label'), "\n";
#7
# print "</body>\n";
# print "</html>\n";
print end_html, "\n";
# end of lect10_04.pl