L
Larry
Hi folks!
I've a couple of questions i wanna ask you:
1) I've been using the code above to decode the form information.
Unfortunately if I call "use strict" at the top of the script it all
wretchedly fail and I get a 500 error from the server...
2) How would you go about setting a postmax value in the
"parse_form_data" of the script? (say,something like $CGI:OST_MAX=1024
* 150
(please don't reply telling me to use CGI.pm because i need to get this
code working)
thanks!
I've a couple of questions i wanna ask you:
1) I've been using the code above to decode the form information.
Unfortunately if I call "use strict" at the top of the script it all
wretchedly fail and I get a 500 error from the server...
2) How would you go about setting a postmax value in the
"parse_form_data" of the script? (say,something like $CGI:OST_MAX=1024
* 150
(please don't reply telling me to use CGI.pm because i need to get this
code working)
Code:
#!/usr/bin/perl
&parse_form_data (*simple_form);
my $user = $simple_form{'user'};
print "Content-type: text/plain", "\n\n";
$user = $simple_form{'user'};
if ($user) {
print "Nice to meet you ", $simple_form{'user'}, ".", "\n";
print "Please visit this Web server again!", "\n";
} else {
print "You did not enter a name. Are you shy?", "\n";
print "But, you are welcome to visit this Web server again!", "\n";
}
exit(0);
sub parse_form_data
{
local (*FORM_DATA) = @_;
local ( $request_method, $query_string, @key_value_pairs,
$key_value, $key, $value);
$request_method = $ENV{'REQUEST_METHOD'};
if ($request_method eq "GET") {
$query_string = $ENV{'QUERY_STRING'};
} elsif ($request_method eq "POST") {
read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
} else {
&return_error (500, "Server Error",
"Server uses unsupported method");
}
@key_value_pairs = split (/&/, $query_string);
foreach $key_value (@key_value_pairs) {
($key, $value) = split (/=/, $key_value);
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
if (defined($FORM_DATA{$key})) {
$FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);
} else {
$FORM_DATA{$key} = $value;
}
}
}
thanks!