I'm sure I'll feel silly when I find out the answer to this!
I have a very simple script and a very simple form.
My problem is that when i send the form variables to the script, I can't do anything with them. See the script below: All I want it to do is print "The item number is "item_number". What I get is "The item number is (blank)"
Can someone please tell me what the problem is?
#!/usr/bin/perl
use strict;
use lib qw(C:/Perl/lib);
use CGI qw
standard escapeHTML);
use DBI;
my $query;
my %form;
my $item_name;
my $item_number;
my @pairs;
my $pair;
my $name;
my $value;
read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
%form = &parse;
$item_name = $form{item_name};
$item_number = $form{item_number};
&deliver_product;
sub parse {
@pairs = split(/&/, $query);
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;
}
sub deliver_product {
print <<EOF;
Content-Type: text/html\n\n
<html>
<head>
<title></title>
</head>
<body>
The item number is $item_number
</body>
</html>
EOF
}
}
exit (0);
And here's the form I use:
<HTML>
<head>
</head>
<body>
<form method="post" action=" target="_blank">
<input type="hidden" name="item_name" value="Fairy Girl on Ladybug Flower">
<input type="hidden" name="item_number" value="BPFAGI0002FWP">
<input type="submit" value="Test IPN">
</form>
</BODY>
</HTML>
I have a very simple script and a very simple form.
My problem is that when i send the form variables to the script, I can't do anything with them. See the script below: All I want it to do is print "The item number is "item_number". What I get is "The item number is (blank)"
Can someone please tell me what the problem is?
#!/usr/bin/perl
use strict;
use lib qw(C:/Perl/lib);
use CGI qw
use DBI;
my $query;
my %form;
my $item_name;
my $item_number;
my @pairs;
my $pair;
my $name;
my $value;
read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
%form = &parse;
$item_name = $form{item_name};
$item_number = $form{item_number};
&deliver_product;
sub parse {
@pairs = split(/&/, $query);
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;
}
sub deliver_product {
print <<EOF;
Content-Type: text/html\n\n
<html>
<head>
<title></title>
</head>
<body>
The item number is $item_number
</body>
</html>
EOF
}
}
exit (0);
And here's the form I use:
<HTML>
<head>
</head>
<body>
<form method="post" action=" target="_blank">
<input type="hidden" name="item_name" value="Fairy Girl on Ladybug Flower">
<input type="hidden" name="item_number" value="BPFAGI0002FWP">
<input type="submit" value="Test IPN">
</form>
</BODY>
</HTML>