0412 899 672

15 Apr 2011

(X)HTML Form Processing

//
Comments0

Overview

Forms let you collect information or data from users. Online shopping, user surveys, search engines and guest books are common uses for forms.

To work, forms require two components: the (X)HTML describing the structure of the form plus either a server-side application or script (usually a CGI script) to process the information that the user enters into the form fields. The resulting effect of the processing script may be to simply send the data entered into the form back to an email address or it may be to send it off to a location for you to access at a later date. (e.g. survey data stored in a database), sometimes an immediate response is provided to the user (eg. content returned as a result of entering search criteria into a form.

All form objects (fields) for an individual form need to be included in a single form element (Insert panel, Forms tab):
<form id="info" method="post" action="cgi-bin/nms-formmail/FormMail.pl">form field objects</form>
. The ‘action’ attribute specifies the location of the processing script on the server which in turn contains information on how to process the form data collected when someone fills in the form and submits it. In Dreamweaver, all attributes for the <form> element can be set by selecting the Form in the Design window or with the Tag selector, then editing attributes in the Properties inspector.

Inside the form element (in Dreamweaver, indicated by an red/orange dashed outline), insert form objects such as text fields, buttons, image fields, checkboxes, radio buttons, list/menus, file fields and hidden fields (Insert panel, Forms tab). Properties can be set in the Properties panel for each object in the form.

How it works

Once the user has finished filling out the form and clicks the submit button, the form is submitted to the CGI script specified in the forms ‘action’ attribute, which in turn processes the form. This CGI script can use the data from the form to send an e-mail message, save the data to a file, query a database and even send a thank you message back to the user’s browser.

Options

Perl is the most common scripting language for form processing; C, Java, and even JavaScript are other options. Web developers skilled in these languages can use a simple text editing program such as Notepad to create these files. There are several sites on the web that offer free CGI scripts that you can either use as is or modify to fit your needs. 2 common options for form processing are available below. You can also ask your sites hosting provider or web team if there are any CGI scripts that are already configured to run on your web server that you can use (most web hosting providers offer these for free with your account via your control panel).

CGI Email (written in C programming language)

This script is the property of: http://web.mit.edu/wwwdev/cgiemail/. See this page for support information.

Pros: A quick and easy option when getting started, as it does not require you to edit a script. You are only required to create a text file (no coding required), define some hidden fields in your form (Insert panel, Forms tab) then upload the text file to your site and the cgiemail file to the cgi-bin folder of your remote site.

Cons: Not very secure. Spambots can access your script and you can expect to receive a few spammy emails generated from your form.

 

MNS FormMail (written using Perl Script)

This script is the property of: http://nms-cgi.sourceforge.net/. See this page for support information.

Pros: More secure and offers greater form management options.

Cons: You will be required to edit the Perl script (FormMail.pl). Full instructions are provided however, editing script can be daunting for new users.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.