I have an html form that uses post
<form name="formname" method="post" action="cgi-bin/feedback.pl">
Here's the perl script:
#!/usr/bin/perl
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Mail::SendEasy;
print "Content-type:text/html\n\n";
my $FormData = "";
# Read the standard input (sent by the form):
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $FormData, $ENV{'CONTENT_LENGTH'});
# Get the name and value for each form input:
@pairs = split(/&/, $FormData);
# Then for each name/value pair....
foreach $pair (@pairs) {
# Separate the name and value:
($name, $value) = split(/=/, $pair);
# Convert + signs to spaces:
$value =~ tr/+/ /;
# Convert hex pairs (%HH) to ASCII characters:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Store values in a hash called %FORM:
$FORM{$name} = $value;
}
}
my $name = $FORM{visitor};
my $email = $FORM{email};
I keep getting and unitialized value message for the read line. It appears that $ENV{'CONTENT_LENGTH'} is null.
Anyone have an idea what I might be doing wrong?
Thanks.
<form name="formname" method="post" action="cgi-bin/feedback.pl">
Here's the perl script:
#!/usr/bin/perl
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Mail::SendEasy;
print "Content-type:text/html\n\n";
my $FormData = "";
# Read the standard input (sent by the form):
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $FormData, $ENV{'CONTENT_LENGTH'});
# Get the name and value for each form input:
@pairs = split(/&/, $FormData);
# Then for each name/value pair....
foreach $pair (@pairs) {
# Separate the name and value:
($name, $value) = split(/=/, $pair);
# Convert + signs to spaces:
$value =~ tr/+/ /;
# Convert hex pairs (%HH) to ASCII characters:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Store values in a hash called %FORM:
$FORM{$name} = $value;
}
}
my $name = $FORM{visitor};
my $email = $FORM{email};
I keep getting and unitialized value message for the read line. It appears that $ENV{'CONTENT_LENGTH'} is null.
Anyone have an idea what I might be doing wrong?
Thanks.