|

Internet Support >> Business
Web Hosting >> adding forms information and example

Adding forms to your web site is a great way to collect meaningful information
from your visitors. People use forms to accept online orders, collect
contact information, etc.
There are a variety of form-to-email scripts avilable on the Internet.
We offer support for Alien
Form by Jon Hedley.
Alien Form and a cgi script that allows you to take information that
is collected via an HTML form on your web page and package it up and send
an e-mail to whatever e-mail address you specify. You do not need programming
knowledge to use this script.
- Download the script: af.txt Make sure
you download this as a plain ASCII text file.
- Now you must configure the script:
- When you open up the script, please make sure your word processor
does not insert any work wraps! The script should be 330 lines long
exactly. Use a script editor or a plain text editor, such as NOTEPAD.
- Set the smtp_server = 'mail.yourdomain.com'
- Set the @Referers = ('www.yourdomain.com','205.216.98.12');
- Rename the script to: af.cgi
- Configure the templates:
- Template file names are arbitrary. Try to use names you will remember,
e.g. "email.txt", "error.txt".
- Wherever you want the user to supply data, use a word inside square
brackets, e.g. [yourname], [age].
- You can have underscores in variables, as long as there is a switch
in front of it.
- You can specify one or more switches on the start of the variables,
e.g. [re_email_address], [d_age].
- Switches allowed:
- r - this value is 'required'- it must be filled in
- e - this value must look like a valid email address
- d - this value may only contain digits (0-9) or a decimal
point (.)
- c - this value can only contain digits, a decimal point,
or a dollar sign ($)
- w - this value may only contain "word" characters
(A-Za-z0-9)
- m - this value can store multiple values (useful for checkboxes
with the same name)
- n - this value will have any new line characters (where
the user has pressed enter) removed
- s - this value's leading and trailing white space will
be removed
- The field names in the HTML must match exactly with those
in the templates. I.E. same switches etc.
- For the email templates, make sure the To: and From: line
will have a valid email address in it (by using the e switch).
If you let the user put in any old information into the To:
line, your email program will generate an error.
- Make sure for email templates that there is a blank line between
the headers and the content.
- Logging templates must have the filename to write to as the
first line. Everything after the first line will be appended
(tacked onto the bottom of) the file specified.
- Fields in the templates such at [%HTTP_REFERER], [%REMOTE_HOST]
will be substituted with their counterpart environment values.
The must begin with a %.
- You cannot require an environment setting- if it is not set
it will be left blank.
- In error templates, the error title is specified as [%OUT_TITLE],
and the error message is specified by [%OUT_MSG].
- To do arithmetic, place the calculation in brackets like [<
... >]. Variables will be filled out before being calculated.
- Examples:
- [< [d_age] / 2 >] - will be given the value of the
value of [d_age] divided by 2
- [< ([item1] + [item2] + [item3]) * [tax] >] - will
add up the items and multiply them by the tax rate
- Remember to save the templates and the script in ASCII or
Plain Text mode.
- Configure the HTML
- All the operations that you want to occur on this iteration are
given in hidden form values. i.e. <input type="hidden"
name="_send_email" value="email.txt">.
- Operations are done in the order specified in the HTML. For this
reason, it is recommended that you specify the browser output last.
- All operations are optional.
- Operations are denoted with a leading underscore.
- They are:
- _send_email - this sends email using the template in this
tag's value
- _out_file - this logs to a file using the template given
in the value
- _browser_out - this displays the value's template in the
browser
- _redirect - this redirects the browser to the URL given
here
- _error_path - if an error occurs, this template is displayed
by the browser
- _error_url - if an error occurs, the browser is redirected
to this URL
- _multi_separator - used with the 'm' value switch, this
specifies which character(s) to use to seperate multiple
value values. Defaults to ', '
- _format_decimals - can be used to format results from
arithmetic calculations- if set to "2", the value
will be rounded to two decimal points.
- You can have more than one _send_email or _out_file, if
you want more than one email sent or file appended to. In
this case, you must specify a unique number or letter after
each one- i.e. _send_email_1, _send_email_2, out_file_a,
_out_file_b, _out_file_c. It really doesn't matter what
you put after them, just as long as each operation is unique.
Make sure the name of each field corresponds exactly to
what you want it to replace in the templates.

Sample HTML Form Code:

The above form utilizes templates and some of the switches:
- _send_email tells it to use the email.txt template to send an e-mail
to me with the information the customer provided
- _send_email_2 does the same thing, but utilizes a different template
and sends the potential customer an automatic reply to their mailbox
letting them know that I got their message.
- _redirect sends them to another web page on my web site that thanks
them for compelting my form
- 'r_name' means that the name field is required
- 're_email" means that not only is the e-mail field required,
but whatever they type in has to resemble an e-mail address, i.e. must
contain something@something.something
- 'address1' and 'address2' is a field that does not necessarily have
to be completed
- 'd_zip' specifies that the data entered in this field can contain
digits only
Sample Template Files:
| Here is my email.txt file: |
 |
| |
|
| Here is my autoreply.txt file: |
 |
If you have additional questions or concerns, please contact
us.
|
|
Friendly Computer Systems, Inc.
& Friendly Network
1383 Main Street, Suite 201
Stevensville, MD 21666
(410) 643.4606 (410) 639.7799 fax: (410) 643.4216
© 2002, Friendly Computer
Systems, Inc. To report problems with this web site, please e-mail webmaster@friend.ly.net
|