Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl print "Content-type: text/html\n\n"; print "<form method='POST' action='/cgi-bin/demo.cgi'>\n"; print "Test Check Box <input type='checkbox' name='CheckBox' value='ON +'></p>\n"; print "<input type='submit' value='Submit' name='Submit'><input type=' +Reset' value='Reset' name='B2'></p>\n"; &ParseForm; foreach $key (sort keys(%formdata)) { print "KEY=$key<br>\n"; print "VALUE=$formdata{$key}<br><br>\n"; } sub ParseForm { 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 "<P>Use Post or Get"; } foreach $pair (@pairs) { ($key, $value) = split (/=/, $pair); $key =~ tr/+/ /; $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; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML Form retaining values
by hardburn (Abbot) on Oct 03, 2003 at 16:43 UTC | |
by tcf22 (Priest) on Oct 03, 2003 at 17:53 UTC | |
|
Re: HTML Form retaining values
by jdtoronto (Prior) on Oct 03, 2003 at 16:44 UTC | |
by Anonymous Monk on Oct 03, 2003 at 17:05 UTC | |
by jonnyfolk (Vicar) on Oct 03, 2003 at 18:20 UTC | |
by Anonymous Monk on Oct 03, 2003 at 21:34 UTC | |
|
Re: HTML Form retaining values
by Hagbone (Monk) on Oct 03, 2003 at 21:37 UTC | |
|
Re: HTML Form retaining values
by mkahn (Beadle) on Oct 03, 2003 at 21:31 UTC | |
|
Re: HTML Form retaining values
by jeffa (Bishop) on Oct 04, 2003 at 14:19 UTC | |
|
Re: HTML Form retaining values
by bean (Monk) on Oct 04, 2003 at 01:35 UTC |