N
Nadine
I have a script to print out the values of a form's fields to a file.
That works fine. However I wanted to print out the values of all the
checkboxes, not just the ones checked, to make analysis easier. I
shortened my script to deal with just the checkboxes until I got this
matter settled. I found several ideas on the web about using param
with checkboxes. I tried two but, being a newbie, I do not know how to
fix the script. Debug says I have compilation errors near line 24 and
"0". I tried a couple things but got nowhere.
My checkboxes are called "c1", "c2", "c3", "c4".
#!/usr/bin/perl -w
use CGI qw
standard);
print "Content-type:text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
print "<html><head><title>Results</title></head>\n";
print "<body>\n";
print "<h2>Results</h2>\n";
@boxes = ("c1", "c2", "c3", "c4");
my $key;
my $box;
foreach $key(@boxes) {
$box=param($FORM{$key})||'0'; # print value or zero
print "$box|\n";
}
print "</body></html>\n";
Thanks in advance for your help.
That works fine. However I wanted to print out the values of all the
checkboxes, not just the ones checked, to make analysis easier. I
shortened my script to deal with just the checkboxes until I got this
matter settled. I found several ideas on the web about using param
with checkboxes. I tried two but, being a newbie, I do not know how to
fix the script. Debug says I have compilation errors near line 24 and
"0". I tried a couple things but got nowhere.
My checkboxes are called "c1", "c2", "c3", "c4".
#!/usr/bin/perl -w
use CGI qw
print "Content-type:text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
print "<html><head><title>Results</title></head>\n";
print "<body>\n";
print "<h2>Results</h2>\n";
@boxes = ("c1", "c2", "c3", "c4");
my $key;
my $box;
foreach $key(@boxes) {
$box=param($FORM{$key})||'0'; # print value or zero
print "$box|\n";
}
print "</body></html>\n";
Thanks in advance for your help.