I have the following code and when I "get" it from the html it shows the code in the browser window. I am new to the server I am using so may not be directing something right. Also, the pl program is in the same directory as the html, maybe it has to be in a cgi folder, I don't know. Does the program look alright? I am having a lot of problems with Perl and CGI so any help would be appreciated.
Thanks
email.pl
#!/usr/bin/perl
%postInputs = readPostInput();
open (MAIL, "|/usr/sbin/sendmail -t" || return 0;
select (MAIL);
print<<"EOF";
To: JeffJ\ @wayne-ent.com
From: $postInputs{ 'email' }
Subject: Message Board Reply
Email Registration
Name: $postInputs{ 'TheName' }
Email: $postInputs{ 'Email' }
Company Name: $postInputs{ 'Company'}
Address: $postInputs{ 'address' }
Phone: $postInputs{ 'Number' }
Contact: $postInputs{ 'Contact' }
Info: $postInputs{ 'Info' }
EOF
close(MAIL);
select(STDOUT);
printThankYou();
sub readPostInput(){
my(%searchField, $buffer, $pair, @pairs);
if($ENV{ 'REQUEST_METHOD'} eq 'POST'){
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;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])
/pack("C", hex($1))/eg;
$searchField{ $name} = $value;
}
}
return (%searchField);
}
sub printThankYou(){
print<<"EOF";
Content-Type: text/html
<HEAD>
<TITLE>THANK YOU FOR REGISTERING!</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="document">
</HEAD>
<BODY>
<TABLE CELLSPACING=2 CELLPADDING=2 border=0 width=600>
<TR>
<BR>
<CENTER>
<FONT SIZE=+3><B>Thank You</b> </font></center><BR><BR>
<CENTER><B> <FONT SIZE=+1>
<P>Thank you $postInputs{ 'Name' } for regisering <BR>
</FONT></B><CENTER>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
EOF
}
Thanks
email.pl
#!/usr/bin/perl
%postInputs = readPostInput();
open (MAIL, "|/usr/sbin/sendmail -t" || return 0;
select (MAIL);
print<<"EOF";
To: JeffJ\ @wayne-ent.com
From: $postInputs{ 'email' }
Subject: Message Board Reply
Email Registration
Name: $postInputs{ 'TheName' }
Email: $postInputs{ 'Email' }
Company Name: $postInputs{ 'Company'}
Address: $postInputs{ 'address' }
Phone: $postInputs{ 'Number' }
Contact: $postInputs{ 'Contact' }
Info: $postInputs{ 'Info' }
EOF
close(MAIL);
select(STDOUT);
printThankYou();
sub readPostInput(){
my(%searchField, $buffer, $pair, @pairs);
if($ENV{ 'REQUEST_METHOD'} eq 'POST'){
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;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])
/pack("C", hex($1))/eg;
$searchField{ $name} = $value;
}
}
return (%searchField);
}
sub printThankYou(){
print<<"EOF";
Content-Type: text/html
<HEAD>
<TITLE>THANK YOU FOR REGISTERING!</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="document">
</HEAD>
<BODY>
<TABLE CELLSPACING=2 CELLPADDING=2 border=0 width=600>
<TR>
<BR>
<CENTER>
<FONT SIZE=+3><B>Thank You</b> </font></center><BR><BR>
<CENTER><B> <FONT SIZE=+1>
<P>Thank you $postInputs{ 'Name' } for regisering <BR>
</FONT></B><CENTER>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
EOF
}