This page will help you get
started with creating a form to collect information and email it
to you. We're going to build a form like the one below.
It is going to use a free
CGI script called "FormMail" to read the form and
email the information to you. "FormMail" is a very
popular script, but earlier versions were vulnerable to SPAM
exploits (in other words, someone else could send SPAM through
your FormMail script and make you look bad). Be sure to use the
secure version (Version 1.9s) which is available in the CGI
Library.
No matter how many forms
you want to have on your site, you only need one copy of
FormMail.pl, even if the forms go to different recipients. The
secure version of FormMail.pl requires you to specify valid
recipients explicitly, and/or the domains of recipients. The
more specific you are, the better, especially if you have your
form email you a domain other than your site.
First, we need to define a
couple of terms:
"Local site"
refers to the working location of your web pages on your PC.
"Remote site"
refers to the /web folder (for you FTP users) of your site
on the server.
Steps:
Build your page and paste the
following html into it:
This should give you a
form that looks like this:
Name:
Email:
Question/Problem:
Finish building your page and save it within
your local site.
Open FormMail.pl in a text editor (WordPad
or Notepad work well).
Find this line:
@recipient_addresses = ();
Enclose your email address in
single quotes and put it inside the parenthesis. If you want
the script to be able to email to other email addresses,
separate these with commas.
Alternatively, you can specify just the
domain name of valid recipients on this line"
@recipient_domains = ();
Just put the domain name in single quotes,
separated by commas, just like step 6 specified for email
addresses.
Save FormMail.pl as text.
Create a cgi-bin folder
within your local site, and copy FormMail.pl there.
Upload the new form and
FormMail.pl (and the cgi-bin folder) to your remote site.
You must perform the following
steps on any CGI script you want a form to use! This is known
what the scripts readme file usually refers to as "chmod
755".
In FTP, navigate to the cgi-bin
folder on your remote site.
Right-click on FormMail.pl to
select it. Most FTP programs will show a pop-up menu.
Select the "CHMOD"
command from the pop-up menu.
Set the permission on
FormMail.pl like this and click OK:
Navigate to your form in your web browser
and test it out.
Troubleshooting:
Problem
Possible Cause
"Permission Denied" error
You didn't CHMOD 755 the script you're trying to call from
the form.
"Not found" error (404)
The path to the CGI script is wrong. Use the full URL to
the script in the "<form action= clause" to
be sure its correct: (http://www.site.com/cgi-bin/FormMail.pl)
You may have a spelling or capitalization error in the
"<form action=clause". Filenames and folder
names are case-sensitive!
"Internal Error"
Something is wrong with the script itself. It may have
been uploaded in binary mode instead of ASCII (Text) mode,
or you didn't close a quote or left a ";" off
the end of a line.
Conclusion:
This page gives the most basic steps for doing
an email form. Read the "Readme" files that come with
FormMail.pl to learn more about other variables that you can use
to do things such as re-direct the browser to another page after
the form is mailed, etc.