Cathryn
06-29-2009, 11:01 PM
Okay, so I'm the first to admit I don't know much about Perl, or forms. But the site I made for my kids' school needs a couple of them.
I did a little online research and got a free mail script, edited it for my usage - which was to allow users to enter their email addy and name to sign up for the newsletter mailing group. This script works fine.
Then I needed another form, for taking details as part of setting up a directory of businesses run by famillies from the school, as part of our fundraising. I used the same pl file as I used on the newsletter, renamed it for the directory and edited bits that needed editing - mostly the print section for when the form has been submitted.
I did the html bit and uploaded both it and the pl file, but the form doesn't work. It returns this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@rockingham.montessori.edu.au and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I've check the path to the perl file, looks fine.
CHMOD the pl file to 755.
I've double checked the code as compared to the newsletter pl code and I can't see any differences.
I tried removing the select and textarea parts of the form, since the newsletter form doesn't have those. No difference.
I'm just stumped and was wondering if anyone would have the time to look over it for me and see what I'm doing wrong?
Link here:
http://rockingham.montessori.edu.au/directory_application.shtml
pl file code:
#!/usr/bin/perl -w
# mail_form.cgi
# bundle up form output and mail it to the specified address
# configuration:
$sendmail = '/usr/sbin/sendmail'; # where is sendmail?
$recipient = 'website.rms@gmail.com'; # who gets the form data?
$sender = 'Anonymous User <website.rms@gmail.com>'; # default sender?
$site_name = 'the directory'; # name of site to return to afterwards
$site_url = 'http://rockingham.montessori.edu.au/directory.shtml'; # URL of site to return to
afterwards
# script proper begins...
use CGI;
$query = new CGI;
# bundle up form submissions into a mail_body
$mail_body = '';
foreach $field (sort ($query->param)) {
foreach $value ($query->param($field)) {
$mail_body .= "$field: $value\n";
}
}
# set an appropriate From: address
if ($email = $query->param('003_email')) {
# the user supplied an email address
if ($name = $query->param('001_name')) {
# the user supplied a name
$name =~ s/"//g; # lose any double-quotes in name
$sender = "\"$name\" <$email>";
} else {
# user did not supply a name
$sender = "$email";
}
}
# send the email message
open(MAIL, "|$sendmail -oi -t") or die "Can't open pipe to $sendmail: $!\n";
print MAIL "To: $recipient\n";
print MAIL "From: $sender\n";
print MAIL "Subject: Mailing List Request\n\n";
print MAIL "$mail_body";
close(MAIL) or die "Can't close pipe to $sendmail: $!\n";
# now show the thank-you screen
print "Content-type: text/html\n\n";
print <<"EOF";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Rockingham Montessori School
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="mont.css">
</head>
<body>
<h1>
Thank you.
</h1>
<p>
Thank you for signing up to the Rockingham Montessori School Business Directory. You will
receive an email within 24 hours detailing payment and image upload options.
</p>
<p>
Return to <A HREF="$site_url" class="p">$site_name</A>.
</p>
</body>
</html>
EOF
[more ....
I did a little online research and got a free mail script, edited it for my usage - which was to allow users to enter their email addy and name to sign up for the newsletter mailing group. This script works fine.
Then I needed another form, for taking details as part of setting up a directory of businesses run by famillies from the school, as part of our fundraising. I used the same pl file as I used on the newsletter, renamed it for the directory and edited bits that needed editing - mostly the print section for when the form has been submitted.
I did the html bit and uploaded both it and the pl file, but the form doesn't work. It returns this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@rockingham.montessori.edu.au and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I've check the path to the perl file, looks fine.
CHMOD the pl file to 755.
I've double checked the code as compared to the newsletter pl code and I can't see any differences.
I tried removing the select and textarea parts of the form, since the newsletter form doesn't have those. No difference.
I'm just stumped and was wondering if anyone would have the time to look over it for me and see what I'm doing wrong?
Link here:
http://rockingham.montessori.edu.au/directory_application.shtml
pl file code:
#!/usr/bin/perl -w
# mail_form.cgi
# bundle up form output and mail it to the specified address
# configuration:
$sendmail = '/usr/sbin/sendmail'; # where is sendmail?
$recipient = 'website.rms@gmail.com'; # who gets the form data?
$sender = 'Anonymous User <website.rms@gmail.com>'; # default sender?
$site_name = 'the directory'; # name of site to return to afterwards
$site_url = 'http://rockingham.montessori.edu.au/directory.shtml'; # URL of site to return to
afterwards
# script proper begins...
use CGI;
$query = new CGI;
# bundle up form submissions into a mail_body
$mail_body = '';
foreach $field (sort ($query->param)) {
foreach $value ($query->param($field)) {
$mail_body .= "$field: $value\n";
}
}
# set an appropriate From: address
if ($email = $query->param('003_email')) {
# the user supplied an email address
if ($name = $query->param('001_name')) {
# the user supplied a name
$name =~ s/"//g; # lose any double-quotes in name
$sender = "\"$name\" <$email>";
} else {
# user did not supply a name
$sender = "$email";
}
}
# send the email message
open(MAIL, "|$sendmail -oi -t") or die "Can't open pipe to $sendmail: $!\n";
print MAIL "To: $recipient\n";
print MAIL "From: $sender\n";
print MAIL "Subject: Mailing List Request\n\n";
print MAIL "$mail_body";
close(MAIL) or die "Can't close pipe to $sendmail: $!\n";
# now show the thank-you screen
print "Content-type: text/html\n\n";
print <<"EOF";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>
Rockingham Montessori School
</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="mont.css">
</head>
<body>
<h1>
Thank you.
</h1>
<p>
Thank you for signing up to the Rockingham Montessori School Business Directory. You will
receive an email within 24 hours detailing payment and image upload options.
</p>
<p>
Return to <A HREF="$site_url" class="p">$site_name</A>.
</p>
</body>
</html>
EOF
[more ....