Hey all! Thanks for everybody’s help so far! Finally got the parsing script
to work! Very excited about that. As a new perl programmer, my confidence is
rising. Just used a cut & paste script, but had to reconfigure. At least I
know what each line of code does (or think I do anyway). Heard that cgi.pm
is better, but am still learning how to use it. Any suggestions?
In the meantime, however, the script prints the form field values in
alphabetical order. I want it to print in the actual order I have it listed
on the form. What to do?
And, in the header of the returned values, I would like the script to say
something like:
At (hh:mm:ss), on (mm/dd/yyyy), “So and So” submitted this request for a
“bla-bla” Quote.
Also, I don’t want the customer to see the returned values; I want them
emailed to me. Once they click the submit button, I just want a page to come
up that says “Thank you for your request”, and so forth and so on. Also, is
this very secure?
Could cgi.pm take care of all of this?
Thanks for your help.
Nathan,
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
www.tandrtrailer.com <http://www.tandrtrailer.com/>
Code follows:
#!c:/perl/bin/perl -w
if ($ENV{'REQUEST_METHOD'} eq 'GET')
{
@pairs = split (/&/,
$ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq
'POST') {
read (STDIN, $buffer,
$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
} else {
print "Content-type: text/html\n\n";
print header;
print "<P>Use Post or Get";
}
foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
# Are these next few lines part of my “alphabetical” problem?
$key =~ s/%([a-fA-F0-9] [a-fA-F0-9])/
pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~s/%([a-fA-F0-9] [a-fA-F0-9])/
pack("C", hex($1))/eg;
$value =~s/<!--(.|\n)*-->//g;
if ($formdata{$key}) {
$formdata{$key} .= ", $value";
} else {
$formdata{$key} = $value;
}
}
print "Content-type: text/html\n\n";
print header;
foreach $key (sort keys(%formdata)) {
print "<P>The field named: <B>$key</B> contained:
<U><B>$formdata{$key}</B></U>";
}