470,827 Members | 1,768 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,827 developers. It's quick & easy.

Cannot access POSTed form data

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
Jul 19 '05 #1
1 3009
Mark wrote:
$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
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Robert Oschler | last post: by
3 posts views Thread by epearce301 | last post: by
7 posts views Thread by php_mysql_beginer911 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.