Click to See Complete Forum and Search --> : CGI PERL Script Problem


reesecup
08-03-2006, 09:19 PM
Hi all,

I really need help with this script. I used this same script before and it worked. I went over it several times and I can't seem to find any errors in the code. I also made sure the I changed the permission, but I am still getting an Internal Server Error Message. I would be so greatful if someone could help me out with this. Thanks!

Here my code:

#!/usr/bin/perl
#sendform.cgi - display web page and send form contents

print "Content-type: text/html\n\n";
use CGI qw(:standard -debug);
use strict;
use Mail::Sendmail;

#declare variables
my ($company, $firstname, $lastname, $address, $snailmail, $city, $state, $zip, $phone, $fax, $ques_comm, $msg, $fmsg, %fmail, %mail);

#declare values
$company = param('coname');
$firstname = param('fname');
$lastname = param('lname');
$address = param('address');
$city = param('city');
$state = param('state');
$zip = param('zip');
$phone = param('pnumber');
$fax = param('fnumber');
$snailmail = param('email');
$ques_comm = param('comments');

#create message 1
$msg = "Thank you, $firstname. This message is a confirmation of your recent request.\n";
$msg = $msg . "We will respond to your request within 24 hours.";

#create message 2
$fmsg = "Company: $company\n";
$fmsg = $fmsg . "First Name: $firstname\n";
$fmsg = $fmsg . "Last Name: $lastname\n";
$fmsg = $fmsg . "Adress: $address\n";
$fmsg = $fmsg . "City: $city\n";
$fmsg = $fmsg . "State: $state\n";
$fmsg = $fmsg . "Zip: $zip\n";
$fmsg = $fmsg . "Phone: $phone\n";
$fmsg = $fmsg . "Fax: $fax\n";
$fmsg = $fmsg . "Email: $snailmail\n";
$fmsg = $fmsg . "Questions/Comments: $ques_comm";


#create acknowledgement
print "<HTML>\n";
print "<HEAD><TITLE>Request Submitted</TITLE></HEAD>\n";
print "<BODY BGCOLOR=BLACK>\n";
print "<IMG SRC=#><BR><BR><BR>\n";
print "<FONT COLOR=WHITE><H3>Thank you, $firstname. Your request was submitted successfully. You will receive an email confirmation shortly.<BR><BR>\n";
print "Here is the information you submitted:</H3>\n";
print "Company: $company<BR>\n";
print "<b>First Name: $firstname<BR>\n";
print "<b>Last Name: $lastname<BR>\n";
print "Address: $address <BR>\n";
print "City: $city <BR>\n";
print "State: $state<BR>\n";
print "Zip Code: $zip<BR>\n";
print "Phone: $phone<BR>\n";
print "Fax: $fax<BR>\n";
print "Email: $snailmail <BR>\n";
print "Questions/Comments:<BR>\n";
print "$ques_comm </b></FONT><BR><BR>\n";
print "<CENTER><A HREF=#></a><FONT COLOR=RED>Return To J&S Transport Home</FONT></A></CENTER> \n";
print "</BODY></HTML>\n";


my %mail = (
From => 'cscott153752MI@comcast.net',
Subject => 'J&S Interstate Trucking - Message Confirmation',
Message => $msg,
Smtp => 'smtp.comcast.net'
);

sendmail(%mail) or die $Mail::Sendmail::error;

my %mail = (
To => 'cscott153752MI@comcast.net',
From => 'cscott153752MI@comcast.net',
Subject => 'Comments/Questions',
Message => $fmsg,
Smtp => 'smtp.comcast.net'
);

sendmail(%mail) or die $Mail::Sendmail::error;

robertketter
08-06-2006, 09:43 AM
I made comments in your code

#!/usr/bin/perl
#sendform.cgi - display web page and send form contents

print "Content-type: text/html\n\n";
use CGI qw(:standard -debug);
use strict;
use Mail::Sendmail;

#declare variables
my ($company, $firstname, $lastname, $address, $snailmail, $city, $state, $zip, $phone, $fax, $ques_comm, $msg, $fmsg, %fmail, %mail);

#declare values
$company = param('coname');
$firstname = param('fname');
$lastname = param('lname');
$address = param('address');
$city = param('city');
$state = param('state');
$zip = param('zip');
$phone = param('pnumber');
$fax = param('fnumber');
$snailmail = param('email');
$ques_comm = param('comments');

#create message 1
$msg = "Thank you, $firstname. This message is a confirmation of your recent request.\n";
##### Here is the first error...
#$msg = $msg . "We will respond to your request within 24 hours.";
$msg .= "We will respond to your request within 24 hours.";

#create message 2
##### Here you made the same error over and over. I have corrected it here already, but left one as an example.
$fmsg = "Company: $company\n";
# $fmsg = $fmsg . "First Name: $firstname\n";
$fmsg .= "First Name: $firstname\n";
$fmsg .= "Last Name: $lastname\n";
$fmsg .= "Adress: $address\n";
$fmsg .= "City: $city\n";
$fmsg .= "State: $state\n";
$fmsg .= "Zip: $zip\n";
$fmsg .= "Phone: $phone\n";
$fmsg .= "Fax: $fax\n";
$fmsg .= "Email: $snailmail\n";
$fmsg .= "Questions/Comments: $ques_comm";


#create acknowledgement
print "<HTML>\n";
print "<HEAD><TITLE>Request Submitted</TITLE></HEAD>\n";
print "<BODY BGCOLOR=BLACK>\n";
print "<IMG SRC=#><BR><BR><BR>\n";
print "<FONT COLOR=WHITE><H3>Thank you, $firstname. Your request was submitted successfully. You will receive an email confirmation shortly.<BR><BR>\n";
print "Here is the information you submitted:</H3>\n";
print "Company: $company<BR>\n";
print "<b>First Name: $firstname<BR>\n";
print "<b>Last Name: $lastname<BR>\n";
print "Address: $address <BR>\n";
print "City: $city <BR>\n";
print "State: $state<BR>\n";
print "Zip Code: $zip<BR>\n";
print "Phone: $phone<BR>\n";
print "Fax: $fax<BR>\n";
print "Email: $snailmail <BR>\n";
print "Questions/Comments:<BR>\n";
print "$ques_comm </b></FONT><BR><BR>\n";
print "<CENTER><A HREF=#></a><FONT COLOR=RED>Return To J&S Transport Home</FONT></A></CENTER> \n";
print "</BODY></HTML>\n";


my %mail = (
From => 'cscott153752MI@comcast.net',
Subject => 'J&S Interstate Trucking - Message Confirmation',
Message => $msg,
Smtp => 'smtp.comcast.net'
);

sendmail(%mail) or die $Mail::Sendmail::error;

my %mail = (
To => 'cscott153752MI@comcast.net',
From => 'cscott153752MI@comcast.net',
Subject => 'Comments/Questions',
Message => $fmsg,
Smtp => 'smtp.comcast.net'
);

sendmail(%mail) or die $Mail::Sendmail::error;


See if this code works now. If not repost error.
Robert Ketter - www.robertketter.com :)

reesecup
08-06-2006, 11:56 AM
Thanks! I got that part working now. However, the send mail module is not working. Any suggestions?