This is not my site, but I was hired on to re-design a site. I have the user name, password, and can upload/delete files. I made the mistake of suggesting a web-form so that visitors can make requests in an organized way instead of littering the site with mailto: links. I haven’t done a form in years and I know ACTION=mailto: isn't kosher anymore.
----------
My goal is to end up with a plain text e-mail with:
Name: (nametextbox)
Phone: (phonetextbox)
e-mail: (e-mailtextbox>
Menu1: (OptionchosenfromMenu1)
Menu2: (OptionchosenfromMenu2)
Menu2: (OptionchosenfromMenu2)
(Lastly, include text from the TextArea box)
(end e-mail)
----------
I have been to a number of websites that either offer free scripts or instructions on how to create your own, but I am either stumped by the vague instructions or it is referring to a file, program, or folder that is not on (or not visible) on the server. Also, every website offers completely different instructions for simple web-forms.
I guess what I saying is "What do I need?" There were no files in the CGI-Bin folder when I got the site. I do not see a folder called SendMail and my repeated attempts at asking my "boss" if these things were included when she got the domain have gone unanswered yet my deadline draws neigh. I do most of my work elbow-deep in HTML code – maybe script coding is too much for me.
So, if you have email.cgi in your cgi-bin directory, your form will have action="/cgi-bin/email.cgi"
It might be easier to test with a simple script just to make sure everything's running. On Unix, I usually bang up a shell script:
#!/bin/sh
echo "Content-type: text/html"
echo
echo "Hello, world!"
If I can access it as /cgi-bin/test.cgi, I'm golden. If not, I start looking at the error I get and such.
Failing all that, ask your provider how to do it. They might even have some recommended templates for scripts.
To write the script, I'd look at CGI.pm, since it handles all the processing.
Sean
I think you are missing the middle parts, a CGI script to "catch" the FORM data and send it out via sendmail.
You FORM "action" would POST to this script.
#!/usr/local/bin/perl
#
# MAILFORM.CGI
#
# set the vars below to meet your needs.
#
$MailTo = 'some.person@domain.tld';
$MailFrom = 'webmaster@domain.tld';
$subject = 'Contact Form (DOMAIN.TLD)';
$HTML_index = 'http://www.domain.tld/';
$dateCmd = '/bin/date';
$mailprog = '/usr/sbin/sendmail';
#
# Parse url for CGI pairs of parameters and values
#
if ($ENV{'QUERY_STRING'}) {
$buffer = $ENV{'QUERY_STRING'};
} elsif ($ENV{'CONTENT_LENGTH'}) {
read (STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
}
#
$txt = '';
#
@cgiPairs = split(/&/,$buffer);
foreach $cgiPair (@cgiPairs) { ($name,$value) = split(/=/,$cgiPair);
$value =~ s/\+/ /g;
$value =~ s/%(..)/pack("c",hex($1))/ge;
$txt .= "$name = $value\n";
}
#
chop ($TimeStamp = `$dateCmd +"%a %D %H:%M %Z"`);
#
open (MAIL,"¦$mailprog -t");
print MAIL "To: $MailTo\nFrom: $MailFrom\n";
print MAIL "Subject: $subject\n";
print MAIL "\n$txt\n(Sent: $TimeStamp)\n\n";
close (MAIL);
#
print "Content-Type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Form Sent</title>\n";
print "</head>\n";
print "<BODY>\n";
print "<BR>Form sent by email $timeStamp<BR><BR>\n";
print "<A HREF=\"$HTML_index\"><B>Click Here<BR>to return to<BR>Home Page</B></A><BR><BR>";
print "</BODY>\n";
print "</HTML>\n";
#
#
Hope this helps.
[edited by: jatar_k at 4:46 pm (utc) on July 25, 2005]
I check off-
"Disable graphic smile faces for this post?"
and
"Disable [codes] for this message?"
Don't know why that got inserted -- I've never seen it before.