CGI/Forms
Important
Basics
Creating
Web pages
FrontPage
CGI
-Cgiemail
-Counters
-FormMail
-Imagemaps
-Mailto
-Password-protected
Web
Directories -PHP/MySQL
Transferring
pages/
Uploading
files
Viewing
pages
What's
wrong?
Announcing
your pages
Commercial
Web stats
|
|
USING CGI / SETTING UP A FORM
|
"I've got a Website. I'd like visitors to fill out a form, then I'd
like the information they fill in to be e-mailed to me. How do I set
that up? It's awfully complicated, isn't it?"
|
No, it's not
complicated. It's called cgiemail form-to-email
gateway . . . and only the name is complicated.
Cgiemail is a public
domain CGI script that takes the information entered into any HTML form,
processes it into an E-mail message, then E-mails the information to you.
Good Web development software already knows how to do this. But
in case you wanted to know how it's done or wanted to set it up
yourself, it's actually quite easy . . .
You'll need:
- The form (in HTML) visitors to your Website will fill
out.
- The "success" or "thank you" or "confirmation" Web page (in
HTML) that will be
displayed when the visitor submits the completed form. It typically
thanks the visitor for filling out the form and provides a link back to
the form.
- A "failed" Web page (in HTML) that will be displayed if the
form submission fails.
- The form results (in text format). When the visitor submits
the completed form, the information that's been entered is E-mailed to
you.
It doesn't matter how you create those three files. You can use
just about any kind of Web page template, HTML editor/Web design software
such as GoLive,
Netscape Gold, Front Page, Hotdog, etc. Or, you
can use Notepad or some other kind of text editor. And once they're
created, you're most of the way there. Then, you modify two tags in your
form's HTML code to set this into motion. What those tags should be are
detailed below.
If you're using FrontPage, go
here
Top of Page
1. Create the Web page that has the form.
|
The form can have as many fields as you want. Once the form is done,
- Modify the POST ACTION tag if it needs it.
- Add a hidden "success" or "confirmation" tag if one isn't there
already.
- Add a hidden "failure" tag if one isn't there already.
What you change the HTML in these tags to depends on what type of account
you have:
and if the form results (the .txt file),
success and failure pages are in the public_html directory or a
sub-directory underneath public_html.
means you edit here if necessary.
COMMERCIAL WEB SPACE WITH a virtual
host URL (URL is
http://www.yourdomain.org/).
<form method=POST
ACTION="/cgi-sys/cgiemail/subdira/subsubdira/form.txt">
I would like to receive more information about:
<textarea name="comments" rows=8 cols=75></textarea>
<input type="hidden" name="success"
value="http://www.yourdomain.org/subdira/subsubdira/success.html">
<input type="hidden" name="failure"
value="http://www.yourdomain.org/subdira/subsubdira/failed.html">
<input type=submit value="Send More Info">
<input type=reset value="Clear Form">
</form>
(The form, form
results, success and failure pages are two subdirectories underneath the
public_html
directory in this example. You don't *have* to put them there. We did
just because we wanted to. Even though you type /cgi-sys/cgiemail in the
form action tag, you don't *have* to create a cgi-sys or cgiemail
directory -- we've already done that for you.
With this type of account,
if you'd *like to* set up your own cgi bin and use your own cgi script,
you
may, as long as the script is not a security hole or CPU hog.
Whether
you
have your own cgi bin or use our shared cgi, what's typed in the form
method tag is the same as indicated below.
For yourdomain.org, substitute your domain name. You don't *have* to name
the form results page form.txt. We named it form because we wanted to.
You don't *have* to name the success page success.html. We named it that
because we wanted to.)
SMALL BUSINESS COMMERCIAL WEB SPACE
withOUT a virtual host URL:
(URL is http://www.mm.com/webdirname)
<form method=POST
ACTION="/cgi-sys/cgiemail/webdirname/subdira/form.txt">
Name: <input name="from_name" size=63>
Your E-Mail: <input name="required-email" size=63>
Address: <input name="address" size=44>
Phone #: <input name="phonenumber" size=32>
I would like to receive more information about:
<textarea name="comments" rows=8 cols=75></textarea>
I found your site through:
<select name="how">
<option>wandered here
<option>Web search
<option>an ad
<option>word of mouth
</select>
<input type="hidden" name="success"
value="http://www.mm.com/webdirname/subdira/success.html">
<input type="hidden" name="failure"
value="http://www.mm.com/webdirname/subdira/subsubdira/failed.html">
<input type=submit value="Send More Info">
<input type=reset value="Clear Form">
</form>
NOTE: The webdirname is a name you requested. It's part of
the URL the outside world uses to look at your Web space.
The webdirname is NOT public_html.
(The form, form results and success page are in a subdirectory --
called subdira -- underneath the public_html directory in this example.
They don't *have* to be in a subdirectory. They can be in
public_html. We used a subdirectory in this example because we wanted to.
Even though you type /cgi-sys/cgiemail in the form action tag, you don't
create a cgi-sys or cgiemail directory -- we've already done that for you.
For webdirname, substitute the name you've told us you want. You
don't *have* to name the form results page form.txt. We named it form
because we wanted to. You don't *have* to name the success page
success.html. We named it that because we wanted to.)
PERSONAL WEB SPACE:
(URL is http://www.mm.com/user/username)
<form method=POST
ACTION="/cgi-sys/cgiemail/user/username/form.txt">
Name: <input name="from_name" size=63>
Your E-Mail: <input name="required-email" size=63>
Address: <input name="address" size=44>
Phone #: <input name="phonenumber" size=32>
I would like to receive more information about:
<textarea name="comments" rows=8 cols=75></textarea>
<input type="hidden" name="success"
value="http://www.mm.com/user/username/success.html">
<input type="hidden" name="failure"
value="http://www.yourdomain.org/subdira/subsubdira/failed.html">
<input type=submit value="Send More Info">
<input type=reset value="Clear Form">
</form>
(In
this example, the form, form
results, success and failure pages are in your public_html directory.
They
don't *have* to be in the public_html directory. They can be in a
sub-directory underneath public_html. We used public_html in this
example because we wanted to. Even though you
type /cgi-sys/cgiemail in the form action tag, you don't create a cgi-sys
or cgiemail directory -- we've already done that for you. For username,
substitute your 3-8 character username. You don't *have* to name
the form results page form.txt. We named it form because we wanted
to. You don't *have* to name the success page success.html. We
named it that because we wanted to.)
Top of Page
2. Create the "success" or "confirmation" Web page.
|
When a visitor fills out your form and submits it, this page will display
to let the visitor know the process was successfully completed. Why have
one? If a visitor to your Website fills out and submits the form, you
don't want the visitor to sit there wondering if the form really was
submitted. Worse, you don't want the visitor to abandon your Website.
You want the visitor to know that it was submited.
For simplicity sake, you might want to name the file "success.html", just
like we've done in our example. But you don't *have* to. You can name it
something else. You can even use the
confirmation.htm or the thank_you.htm file generated by FrontPage.
What the "success" or "confirmation" Web page looks like is up to you.
Don't forget to put a link back to the form on the page.
Top of Page
3. Create the "failure" Web page.
|
Create the "failed" Web page like you would the "success" or
"confirmation" page. The "failed" Web page displays when the form cannot
be submitted successfully. It usually says the form could not be
submitted, gives some basic instructions on what's wrong (most common
reason a form fails is a required field was left blank), and contains a
link back
to the form so that the form can be filled out properly and re-submitted.
Top of Page
4. Create the template (boiler plate) for the form results.
|
When the visitor submits the completed form, the information that's been
entered is E-mailed to you. How that information looks or is formatted in
the e-mail message depends on how you set up the form results boiler
plate or template.
That's an advantage to using cgiemail - you get to set up the form's
results
in a way that's easiest for you to read. If you've never set this up
before -- that's because you've never had a
choice about how the results can look. We let you choose.
Please note:
- The first line must be the From: line and
contain the field for the
e-mail address of the person filling out the form. To make sure the e-mail
address isn't
accidentally left blank, it should be a required field, as we've done in
our example.
-
The second
line must be the To: line and contain the actual e-mail
address
you'd like the form results
e-mailed to, whether it's you, someone else, you and someone else, or you
and several someones.
This/These e-mail address/es don't come from a field; you need to type
it/them
in the .txt file. If
you want the form results to go to you *and* someone else, separate the
e-mail addresses by a
comma and one space.
- Field names enclosed in square brackets will be substituted with the
value entered by the user. It might look like the one below.
Fields that have required- in them are required.
Example:
From: [required-email]
To: persontoreceivetheresults@yourdomain.org
Subject: cgiemail from [from_name]
[from_name] visited your Website. My E-mail address is [required-email]
and my phone number is [phonenumber].
I'd like more information about:
[comments]
I found your Website by: [how]
When it's e-mailed to you, it will look like an e-mail
message:
From: visitorX@visitorsisp.com
To: persontoreceivetheresults@yourdomain.org
Subject: cgiemail from Jane Doe
Jane Doe visited your Website. My E-mail address is
visitorX@visitorsisp.com and my phone number is private.
I'd like more information about:
The weather in Minnesota because I'm thinking of moving there.
I found your Website by: a search engine.
Top of Page
5. Test the form to make sure it works.
|
Fill out the form correctly (don't skip any required fields) and click the
submit button. Make sure the success page displays and there's a link
back to the form. Make sure the results
were e-mailed to the address you hard-coded into the .txt page. Make sure
the results look like you want. Change whatever you think needs to be
changed. Fill out the form again, except this time skip a required field.
Make sure the failed page displays and there's a link back to the form.
If you need more details, they're available on the
cgiemail home page.
Top
Copyright © 1994-2008 by Minnesota MicroNet. All
rights reserved.
|