The DATABASE1.PL Script is no longer intended for use. This documentation is kept online as a reference for forms yet to be converted to FORMMAIL2.PL or DATABASE2.PL Script. PLEASE see FORMMAIL2.PL Documentation or DATABASE2.PL Documentation.

Using the DATABASE1.PL Script

Last revised February 12, 1999

It is now possible to set up a web form that records data from users in a format that you can import into Microsoft Access or Excel. This method works with with Microsoft Access versions 2 or later, and Microsoft Excel version 7 or later. The import instructions are for version 7 for Windows 95, but other versions are extremely similiar.

You can use this method with an existing Access database, provided that there are only "standard" type fields, and the last field in the structure is a "date" type field. "Standard" field types are text, memo, date, numeric (number), or currency. The last field, a "date" type, is used to record what date the user input was done. If you already have a "date_input" field, you can move it to the end of the structure, else just add another field to your structure.

It is probably best to set up a database table and then design your html form, but MS Access will import the data from the web into a new table on-the-fly, and allow you to name the fields and field types (but not lengths).

There are several example forms you can look at, download and change to get started fast. There are even matching databases written in Access that you can use (you will need to "unzip" these). But if you need something very customized, you can build it using the instructions that follow. Please note that the ready-to-use Access databases that you can download from the three links below all were created with MS Access version 7.

Example Forms - HTML Source - Access Databases
1 A Simple Order Form - a good example of various form elements and their Access counterparts HTML Source Access Database
2 A Sample Guest Book form HTML Source Access Database
3 A multiple-choice survey HTML Source Access Database

Prerequisites
You should be familiar with MS Access and html forms before trying to use the DATABASE1.PL script. However, you can get off to a quick start by using one of the above example forms and making minor changes to it. If you would like to take a refresher course on forms, click here. If you like online tutorials, you might want to visit Microsoft's Access Online Tutorial.


Some Important Notes

Before getting too involved, you should know that:

The Desktop (Access) Table

Table Structure
The only thing you really must have is a date (or "date/time") field and it must be the last field in the table structure. If you want to keep track of user's IP addresses, the IPaddress field must be next to last (right before the date). Whether IP addresses are recorded is controlled by the savehostaddr field (see note below).

Other than that, you may have fields of the type listed above (in the second bullet under Some Important Notes). The overall size limit of data transmission is about 1K, so you will not want to have so many fields or huge fields that more than 1024 characters of input are submitted by the user at a single time.


Setting Up the HTML Form

The FORM ACTION line
The ACTION= line of your form needs to point to "/cgi/database1.pl". You should use "POST" as the method. In other words, your form definition should begin with:
      <FORM METHOD=POST ACTION=http://www.ianr.unl.edu/cgi/database1.pl>
Special Hidden Fields
There are several hidden fields you MUST have on your form, or else it won't work. These are:

Using MAXLENGTH to control input
It is a good idea to use the MAXLENGTH property on HTML forms to limit input on text fields. You don't want the user to type in more than your Access table will hold. So for example, if your "NAME" field in Access is defined as text, 20 characters, you'd of course set MAXLENGTH to 20.

Logical (Yes/No) Fields
Logical fields should be set up so that a true (or checked) value is "TRUE" (with the quotes) and false returns "FALSE". One way to do logical fields is with two radio buttons per field, as shown below:

Are you a logical person? <INPUT TYPE="radio" NAME="logiperson" VALUE="TRUE">Yes
  <INPUT TYPE="radio" NAME="logiperson" VALUE="FALSE">No

Another way of using logical fields is to use a single checkbox for the field:

<INPUT TYPE="checkbox" NAME="logiperson" value="TRUE"> Check here if you're logical
Notes:

Remember...


Appending the Data to an Access Table

  1. Open your Access database (.mdb) file.
  2. Open the File menu, Get External Data, Import...
  3. Change "Files of Type:" to Text Files
  4. Navigate to where you downloaded your file (presumably with a .TXT extension). The instructions on how or what to download are not listed in this document, but are available upon request to IANR departments with pages on the IANR web server.
  5. Double-click the file name
  6. The Text Import Wizard appears. Make sure "Delimited" is selected (not Fixed Width)
  7. Click on Next. Make sure the "Comma" radio button is selected as delimiter, and Text Qualifier is a double quote (") mark.
  8. Click on Next.
  9. If you are appending (adding to) an existing table, select "In an existing table", and select the table. Otherwise, select "In a New Table", and allow Access to build the table for you.
  10. If you clicked on "Existing Table" - click on Next, then Finish.
  11. If you clicked on "Into a New Table" - click on Next, and rename fields and specify field types, if you want to. Then click on Finish.

Credits: DATABASE1.PL was written by Al Arnold. Thanks also to Matthew M. Wright for the parsing routines.