Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl/Flash web form

         

ngiline

4:41 pm on Apr 20, 2004 (gmt 0)


I have implemented a flash form and used cgi/perl to back it up, but it doesn't seem to want to work properly. Here's my error:

[Tue Apr 20 11:35:19 2004] [error] [client 24.198.134.42] File does not exist: /home/myan/public_html/500.shtml
[Tue Apr 20 11:35:19 2004] [error] [client 24.198.134.42] Premature end of script headers: /home/myan/public_html/cgi-bin/cmail.cgi
[Tue Apr 20 11:35:19 2004] [error] (2)No such file or directory: exec of /home/myan/public_html/cgi-bin/cmail.cgi failed

I have chmod'd everything to 755 and I also escaped the recipient address ($recipient = "me\@example.com";[smilestopper])

I have checked my bin/lib and they are correct (#!/usr/bin/perl) ($mailprog = "/usr/sbin/sendmail";[smilestopper]) but I still cannot seem to figure out the problem. I got the coding from an experienced coder, and here is the pl file (cmail.cgi) with heavy commenting for easier understanding.

#!/usr/bin/perl
# NOTE- on above line- your path to PERL could be different!
# If you're not sure, check with your web host.
###########################################################
# accepts data post from 'contact us' page and emails data
###########################################################
# NOTE- again, your path to sendmail could be different
$mailprog = "/usr/sbin/sendmail";
# NOTE- this is where you want the email sent to.
# Be sure and "escape" the "@" sign.
$recipient = "me\@example.com";
# get the input
# put it in $buffer
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# split the input into name-value pairs
@pairs = split(/&/, $buffer);
# standard processing loop
# this will un-URLencode as many variables as you send and place
# in an array ($FORM).
foreach $pair (@pairs) {
# split the name-value pair into name and value
($name, $value) = split(/=/, $pair);
# convert '+' to space
$value =~ tr/\+/ /;
# convert embedded comma to space delimiting purposes
$value =~ tr/\,/ /;
# convert hex symbols to alphanumeric
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/ge;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("c", hex($1))/ge;
$value =~ s/<!--(.¦\n)*-->//g;
# create new array with each name and value as elements
$FORM{$name} = $value;
}
# now assign a variable name to each value from the input array
$NAME = $FORM{'name'};
$EMAIL = $FORM{'email'};
$SUBJECT = $FORM{'subject'};
$MESSAGE = $FORM{'message'};
# next we have to re-URLencode any values being sent back to flash.
# for my contact form I'm only going to send the name.
$NAME =~ tr/ /\+ /;
# this assigns a "name" to our name/value pair being sent
# and sends it back to flash through the standard output stream.
# be sure and note the content type!
print "Content-type: application/x-www-urlform-encoded\n\n";
print "rtn_name=$NAME";
# now we open a stream to "sendmail" and send the email
# using the variables from above.
open (MAIL, "¦$mailprog $recipient"[smilestopper]) ¦¦ die "Can't open $mailprog!\n";
print MAIL "To: $recipient\n";
print MAIL "From:$EMAIL\n";
print MAIL "Subject: $SUBJECT\n";
print MAIL "------------------------------------------------------\n";
print MAIL "$MESSAGE\n\n";
print MAIL "$NAME\n";
close (MAIL);
exit;

Any help would be GREATLY appreciated! =]

eric

VectorJ

2:23 am on Apr 21, 2004 (gmt 0)

10+ Year Member



It looks like you don't have permission to execute sendmail from a cgi. Try running sendmail from the command line to see if you can do it or if its execution is restricted by your webhost.