Friendly Network Logo/ Banner
 


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.

  1. Download the script: af.txt Make sure you download this as a plain ASCII text file.
  2. Now you must configure the script:
    1. 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.
    2. Set the smtp_server = 'mail.yourdomain.com'
    3. Set the @Referers = ('www.yourdomain.com','205.216.98.12');
    4. Rename the script to: af.cgi
  3. Configure the templates:
    1. Template file names are arbitrary. Try to use names you will remember, e.g. "email.txt", "error.txt".
    2. Wherever you want the user to supply data, use a word inside square brackets, e.g. [yourname], [age].
    3. You can have underscores in variables, as long as there is a switch in front of it.
    4. You can specify one or more switches on the start of the variables, e.g. [re_email_address], [d_age].
      1. Switches allowed:
        1. r - this value is 'required'- it must be filled in
        2. e - this value must look like a valid email address
        3. d - this value may only contain digits (0-9) or a decimal point (.)
        4. c - this value can only contain digits, a decimal point, or a dollar sign ($)
        5. w - this value may only contain "word" characters (A-Za-z0-9)
        6. m - this value can store multiple values (useful for checkboxes with the same name)
        7. n - this value will have any new line characters (where the user has pressed enter) removed
        8. s - this value's leading and trailing white space will be removed
      2. The field names in the HTML must match exactly with those in the templates. I.E. same switches etc.
      3. 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.
      4. Make sure for email templates that there is a blank line between the headers and the content.
      5. 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.
      6. Fields in the templates such at [%HTTP_REFERER], [%REMOTE_HOST] will be substituted with their counterpart environment values. The must begin with a %.
      7. You cannot require an environment setting- if it is not set it will be left blank.
      8. In error templates, the error title is specified as [%OUT_TITLE], and the error message is specified by [%OUT_MSG].
      9. To do arithmetic, place the calculation in brackets like [< ... >]. Variables will be filled out before being calculated.
        1. Examples:
        2. [< [d_age] / 2 >] - will be given the value of the value of [d_age] divided by 2
        3. [< ([item1] + [item2] + [item3]) * [tax] >] - will add up the items and multiply them by the tax rate
      10. Remember to save the templates and the script in ASCII or Plain Text mode.
  4. Configure the HTML
    1. 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">.
    2. Operations are done in the order specified in the HTML. For this reason, it is recommended that you specify the browser output last.
    3. All operations are optional.
    4. Operations are denoted with a leading underscore.
      1. They are:
        1. _send_email - this sends email using the template in this tag's value
        2. _out_file - this logs to a file using the template given in the value
        3. _browser_out - this displays the value's template in the browser
        4. _redirect - this redirects the browser to the URL given here
        5. _error_path - if an error occurs, this template is displayed by the browser
        6. _error_url - if an error occurs, the browser is redirected to this URL
        7. _multi_separator - used with the 'm' value switch, this specifies which character(s) to use to seperate multiple value values. Defaults to ', '
        8. _format_decimals - can be used to format results from arithmetic calculations- if set to "2", the value will be rounded to two decimal points.
        9. 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:

  1. _send_email tells it to use the email.txt template to send an e-mail to me with the information the customer provided
  2. _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.
  3. _redirect sends them to another web page on my web site that thanks them for compelting my form
  4. 'r_name' means that the name field is required
  5. '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
  6. 'address1' and 'address2' is a field that does not necessarily have to be completed
  7. '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