I rewrote a program to pass on values from an HTML program to a CGI program. However, the CGI is not printing it. I suspect that the program is not receiving the data. I have used the same code in other programs and it works. Please help. The CGI program is:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI;
$query = new CGI;
print "test";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
%FORM = ();
foreach $pair (@pairs) {
$pair =~ s/\+/ /g;
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/\n/ /g; # replace newlines with spaces
$value =~ s/\r//g; # remove hard returns
$value =~ s/\cM//g; # delete ^M's
$FORM{$name} = $value;
}
foreach $key('make','model','mile','year','price')
{
print " $FORM{'make'}<br>";
print " $FORM{'model'}<br>";
print " $FORM{'mile'}<br>";
}
print "test1";
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI;
$query = new CGI;
print "test";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
%FORM = ();
foreach $pair (@pairs) {
$pair =~ s/\+/ /g;
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/eg;
$value =~ s/\n/ /g; # replace newlines with spaces
$value =~ s/\r//g; # remove hard returns
$value =~ s/\cM//g; # delete ^M's
$FORM{$name} = $value;
}
foreach $key('make','model','mile','year','price')
{
print " $FORM{'make'}<br>";
print " $FORM{'model'}<br>";
print " $FORM{'mile'}<br>";
}
print "test1";