Cannot access POSTed form data

M

Mark

I'm no Perl expert so I basically copied this code from a tutorial and I'm
not totally clear how it works. However, I am having trouble accessing the
POST variables that are posted to my page from another form on a different
server.

This is the code I am using to get at the variable:

#!/usr/bin/perl

# orderform.cgi

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 <<END_of_multiline_text;
Content-Type: text/html; charset=ISO-8859-1

<...html code here...>

END_of_multiline_text;

Okay, in that HTML section I refer to my variable in the following line:

<p>Your order is worth a total of:
<strong>&pound;$FORM{'grandtotal'}</strong></p>

However, the variable just displays a blank. I've a very rough idea of what
the code is doing but I've seen it posted on several tutorial sites so I
presume it's a pretty standard way of accessing form data. I think there
must be something wrong with how I call the variable in the HTML paragraph.

Thanks
Mark
 
J

Joe Smith

Mark said:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$Form{$name} = $value;

UGH! You really ought to be using code that does it right, like CGI.pm
instead of leaving yourself vulnerable to a denial-of-service attack.
<strong>&pound;$FORM{'grandtotal'}</strong></p>

$FORM is not the same as $Form.
-Joe

P.S. Next time post to comp.lang.perl.misc and not comp.lang.perl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top