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

# will this save the info from the form on class9_06.html?

open HTML_INFO, ">> class9_06_sent_info"
   or die "Cannot open class9_06_sent_info: $!";

# first: get the information from the HTML form as one big string:

read STDIN, $info_string, $ENV{"CONTENT_LENGTH"}; 

# try to save it to class9_06_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";
}
    
close HTML_INFO;

# try to send back a confirmation page

print "Content-type: text/html", "\n\n";
print "<html>\n";
print "<head><title>Confirmation</title></head>\n";
print "<body><h1>Confirmation</h1>\n";
print "<hr>\n";
print "Information transferred?<br>";
print "name given was: ", $field_value_hash{"desired_label"}, "\n";
print "</body>\n";
print "</html>\n";

# end of class9_06.pl