Hey All, I'm new to Perl and cou
Hey All, I'm new to Perl and cou
(OP)
Hey All,
I'm new to Perl and could surely use your help. I've created a script and placed it in my cgi-bin, however, I get the following error message instead: Premature end of script handler /data1/hm/harmani.com/cgi-bin/form.cgi
At present, my form is located at http://www.harmani.com/feedback/form.html
the following is my script:
#!/usr/local/bin/perl
&get_form_data();
&send_email;
&print_thankyou_paga;
sub get_form_data
{
#Get the input
read(STDIN, $buffer,$ENV{'Content_Length'} );
#Split the name-value pairs
@parirs=split(/&/, $buffer);
foreach $pair (@paris)
{
($name, $value)=split(/=/, $pair);
#Un-Webify plus signs and %-encoding
$value=~tr/+/ /;
$value=~s/%[a-fA-FO-9][a-fA-FO-9])/pack("C",
hex($!))/eg;
$value=~s/<!--(.|\n)*-->//g;
$FORM($name)=$value;
}
}
sub send_email
{
$to="ceo\@harmani.com";
open(MAIL, "/var/qmail/bin/qmail-inject -t $to") || die
("can't open sendmail");
print MAIL "From: $FORM{'email'}\n";
print MAIL "To: $to\n";
print MAIL "Subject: Form submission\n\n";
# print out the form results
print MAIL "Name: $FORM{'Name1'}\n";
print MAIl "Title: $FORM{'Title'}\n;
print MAIL "E-mail: $FORM{'Email'}\n;
print MAIL "Address: $FORM{'Address'}\n;
print MAIL "Gender: $FORM{'Gender'}\n;
print MAIL "Age: $FORM{'Age}\n;
print MAIL "Date of Birth: $FORM{'DOB'}\n;
print MAIL "How did you find out about Harmani?: $FORM{'Info1'}\n;
print MAIL "What is it that you like about Harmani?: $FORM{'Info2'}\n;
print MAIL "What would you like to see improved at Harmani?: $FORM{'Comment'}\n;
close (MAIL);
}
sub print_thankyou_page
{
print "Content-type: text/html\n\n";
print "<HTML>\n<HEAD>\n<BODY BGCOLOR=\"#FFFF99\">\n
</HEAD>";
print "<H3>Thank you</H3>\n\n";
print "<P>\n";
print "Thank you for your submission\n";
print "<P>\n";
print "<A HREF=\"http://www.harmani.com/glance.html\">Return</A>to the home page\n";
}
print "</BODY<\n</HTML>";
I'm new to Perl and could surely use your help. I've created a script and placed it in my cgi-bin, however, I get the following error message instead: Premature end of script handler /data1/hm/harmani.com/cgi-bin/form.cgi
At present, my form is located at http://www.harmani.com/feedback/form.html
the following is my script:
#!/usr/local/bin/perl
&get_form_data();
&send_email;
&print_thankyou_paga;
sub get_form_data
{
#Get the input
read(STDIN, $buffer,$ENV{'Content_Length'} );
#Split the name-value pairs
@parirs=split(/&/, $buffer);
foreach $pair (@paris)
{
($name, $value)=split(/=/, $pair);
#Un-Webify plus signs and %-encoding
$value=~tr/+/ /;
$value=~s/%[a-fA-FO-9][a-fA-FO-9])/pack("C",
hex($!))/eg;
$value=~s/<!--(.|\n)*-->//g;
$FORM($name)=$value;
}
}
sub send_email
{
$to="ceo\@harmani.com";
open(MAIL, "/var/qmail/bin/qmail-inject -t $to") || die
("can't open sendmail");
print MAIL "From: $FORM{'email'}\n";
print MAIL "To: $to\n";
print MAIL "Subject: Form submission\n\n";
# print out the form results
print MAIL "Name: $FORM{'Name1'}\n";
print MAIl "Title: $FORM{'Title'}\n;
print MAIL "E-mail: $FORM{'Email'}\n;
print MAIL "Address: $FORM{'Address'}\n;
print MAIL "Gender: $FORM{'Gender'}\n;
print MAIL "Age: $FORM{'Age}\n;
print MAIL "Date of Birth: $FORM{'DOB'}\n;
print MAIL "How did you find out about Harmani?: $FORM{'Info1'}\n;
print MAIL "What is it that you like about Harmani?: $FORM{'Info2'}\n;
print MAIL "What would you like to see improved at Harmani?: $FORM{'Comment'}\n;
close (MAIL);
}
sub print_thankyou_page
{
print "Content-type: text/html\n\n";
print "<HTML>\n<HEAD>\n<BODY BGCOLOR=\"#FFFF99\">\n
</HEAD>";
print "<H3>Thank you</H3>\n\n";
print "<P>\n";
print "Thank you for your submission\n";
print "<P>\n";
print "<A HREF=\"http://www.harmani.com/glance.html\">Return</A>to the home page\n";
}
print "</BODY<\n</HTML>";
RE: Hey All, I'm new to Perl and cou
This line,
&print_thankyou_paga;
appears to be trying to call a non-existent sub. Maybe it needs to be
&print_thankyou_page;
The premature end of script header' complaint usually means that for some reason you are not sending the 'Content-type....' line back to the browser. Either your code is blowing up before or you simply are not doing it. In this case, upon a very superficial inspection, it appears you are not actually calling the sub that would create that output.
HTH
keep the rudder amid ship and beware the odd typo
RE: Hey All, I'm new to Perl and cou
I modified the sub script portion as you suggested, but I'm still getting the same error. I could surely use your help.
shake & bake
RE: Hey All, I'm new to Perl and cou
keep the rudder amid ship and beware the odd typo