Helpful Tips & Techniques

Forms in WebExpress

 

New Forms in WebExpress 3.0

The following is a quick guide to using forms with WebExpress v3.0. In particular, this discussion relates to the new form handler, mvforms.cgi. Before we go into that too much, however, a quick introduction to the Form Wizard is in order.

The Form Wizard is activated whenever you create a new form in WebExpress. This is typically done with the Create Form selection from the Insert menu.

The Form Wizard walks you through the creation of an interactive form, allowing you to collect valuable information from visitors to your site. You can choose to create a new form from one of the pre-set templates (highly recommended) or start from scratch.

Even if one of our form templates doesn't match your specific needs, they usually provide an excellent starting point. Additionally, if you choose to use the new WebExpress Form Handler, it takes care of setting up the details for you.

Top

The WebExpress Form Handler

The WebExpress Form Handler, mvforms.cgi, is a cgi program to handle forms within WebExpress. The program is written in Perl, a popular language for cgi programs on the web because it is compatible with UNIX, Windows NT, and other popular web servers.

If you use the Form Wizard in WebExpress, you can optionally choose to use mvforms.cgi, or as it is called in the Form Wizard, the WebExpress Form Handler. The Form Wizard will take care of most of the details of using mvforms.cgi for you. This document explains those details, and shows you how you can extend its use.

Top

Form Handler Basics

A form handler manages the exchange of data after it has been submitted by a user in their web browser. The browser collects the data from the user, and then passes this data off to the form handler. The form handler then processes the data in an appropriate fashion, in this case by sending the data back to you via email.

The data typed by the user is entered into form fields. These are fields you set up within WebExpress. The Form Wizard gets you started with commonly used forms. You can easily add other fields using the form tools.

A second type of field is known as a “hidden” field. These generally provide directions to the form handler telling it how the data should be processed. The Form Wizard asks all the necessary questions and fills in all the hidden fields required by mvforms.cgi.

Top

Forms and Your Web Host

In order to use mvforms.cgi, you will need to understand your ISP’s (or web hosting service) policies on cgi scripts. Since a cgi script is an executing computer program, some ISPs prevent them from being used on their systems. Others require them to be checked out by them first, and then installed into a special location.

More and more ISPs, however, provide you a special location on your web site to install cgi scripts. This is typically a special directory named cgi-bin or cgi-local. Inquire with your ISP to find out the name of the location for cgi scripts, and have it ready when you run the Form Wizard.

Top

Nasty Details: If Something Goes Wrong

There are a couple of nasty technical details that you have to attend to if your forms don’t work right off the bat. You will need to ask your ISP for information, and change the mvforms.cgi file itself (using a standard text editor). Sorry about this, but they are necessary evils.

  • The first nasty technical detail is the location of the Perl Interpreter on your ISP’s system. You don't really need to understand the details, but if it isn’t:

    #!/usr/local/bin/perl

    you will need to change the first line of mvforms.cgi to whatever your ISP tells you.

  • For Unix ISPs, you may also have to change the location of their sendmail program. This is on the second line of mvforms.cgi. If it isn’t:

    "/usr/lib/sendmail -t"

    you will need to change it to whatever your ISP tells you.

  • For Windows NT ISPs, you will have to specify the SMTP address. This is on the third line of mvforms.cgi. If it isn’t:

    smtp.yourname.com

    you will need to change it to whatever your ISP tells you.

Top

Field Naming Conventions

By default, mvforms.cgi sorts the fields in alphabetical order when preparing its email response. To give you total control over the order of the data in your form, the first two letters of each field name are used as sort characters. They are then stripped off when preparing the response. An example best illustrates this.

Let’s say your have three fields in your form: Name, Address and City. If you named your fields Name, Address and City (totally logical), your response email would look like this:

Address:   123 First Street

City:          San Diego

Name:       John Smith

The order is not too logical. However, taking advantage of mvform’s method of stripping the first two characters, you can better control the order. By naming your fields like this: aaName, abAddress, acCity, your email response looks like this:

Name:       John Smith

Address:   123 First Street

City:          San Diego

This reads much better. Remember this when adding new fields to a form using mvforms.cgi. The Form Wizard already uses this technique, so you won’t have to worry about its fields.

Top

Hidden Fields

The Form Wizard adds all required hidden fields to your form automatically, but we list them all here for reference. The most important thing to remember is that all hidden fields for mvforms.cgi begin with a period ( . ), for example .email_dest. To edit hidden fields in WebExpress, use the Form Properties dialog.

.email_dest

This should be set to the email address of the person receiving the email responses. The Forms Wizard will prompt you for the e-mail address.

.intro

The value for this field will be used to begin the body of the e-mail response message. The Form Wizard gives the option of setting this value. If nothing is entered, the default value is:

The following information has been submitted:

.subject

This value will appear in the subject line of the e-mail response message. The Form Wizard gives you the option of setting this value. If nothing is entered, the default value is: Form Response.

Top

Optional Hidden Fields

The following hidden fields may be used to give the behavior that you desire.

.thanks_url

Once a user has submitted a form, use this field to direct the browser to a page acknowledging the submission. If you don’t supply a URL here, a generic message will be issued from mvforms.cgi.

.remove_indexing

This field will stop mvforms.cgi from stripping the first two letters of the field name in the email response. Remember that the fields will still be sorted alphabetically, and you will have no other control over field order. Set this value to 1 to strip the two characters, otherwise set it to 0.

.required

If you would like to be sure certain fields are filled in before a form is submitted, add this to your Form Properties. In the value field, enter the name of each required field (the name must be an exact match). Separate field names in the list with a semicolon (;).

Top

Customizing the Script

Mvforms.cgi uses many strings for default responses. You can customize these by changing the mvforms.cgi file itself, using a standard text editor. You should do so with care, but we have made them easy to find. Look for this comment before each text string which may be changed:

#************** CUSTOMIZABLE TEXT ****************

Remember that a text sting looks like this, "blah, blah, blah" and that anything in a text string that starts with a $ sign is a variable name and should not be changed (e.g. $string = "Some text with a $variable embedded.\n"; ).

Some familiarity or knowledge of Perl scripts will be most useful if you intend to do any extensive customization.

Top

Transferring to Your Web Site

If you use WebExpress to transfer files to your web site, it will automatically transfer mvforms.cgi correctly. If you use some other FTP software, you must remember to set the file transfer mode to ASCII before sending the file. Failing to do so will surely result in errors when submitting the form.

Top

This web site was created with WebExpress version 3.0 on February 19, 1998. Please send your comments or questions to MicroVision Technical Support: [email protected]
© 1998 MicroVision Development, Inc. All rights reserved.