Wright State University home page. Communications and Marketing
Services
Design
Development
Support
Guides and Standards
Accessibility
Forms
Imagery
Policy
Style
Usability
Web Administrators
Access Request
Contact List
Meeting Notes
Web Team

Guides & Standards - Forms - cgifile

The cgifile program, located on the main Web server, gives you the ability to append information to a file and ultimately import the results into databases. This utility will only work for Web files on the main Web server (www.wright.edu).

Refer to http://www.wright.edu/web/resources/formcgifile.html to see a working example of a form using the cgifile program.

separator

Step 1: Create Your cgifile Template and incoming.txt File

Before you may receive any entries to later be imported, you must first create a text file that contains the guidelines regarding the user's submissions. You must define what information you want to receive, and also the order in which you would like it to be listed.

[firstname]|[lastname]|[gender]|[status]|[class]|[housing]|[comments]
insert blank line

The blank line is required so that each submission will be written on a new line, and make importing into a database possible. Also, instead of using commas to distinguish different fields, you may use other special characters (e.g. - $, %, *). In naming the template, it is helpful to use the same filename as the form - with a .txt extension.

Further, you must create an empty text file that will house the results submitted by the user. Each individual entry will be created on a new line and will be appended to the data file. This empty text file must be named "incoming.txt" when using cgifile and must be placed in the same directory as the template text file.

After you have created the incoming.txt file and placed it on the main Web server, e-mail the WSU Web Team (webmaster@wright.edu) so that we can set the correct permissions for the file. Tell us your name, username, and the web address of the incoming.txt file.

Note: Save the files as ASCII text.

Now you are ready to create the HTML form.

separator

Step 2: Create the Form

Example:

<form action="http://www.wright.edu/cgibin/cgifile/web/resource/cgifile.txt" method="post">

<p>
First name: <input type="text" name="firstname">
</p>

<p>
Last name: <input type="text" name="lastname" value="last name here">
</p>

<input type="radio" name="gender" value="Male"> Male
<input type="radio" name="gender" value="Female"> Female

<p>
Who are you?
<input type="radio" name="status" value="Student"> Student
<input type="radio" name="status" value="Parent"> Parent
<input type="radio" name="status" value="Alumni"> Alumni
</p>

<p>
If you are a student, what is your class rank?
</p>

<select name="class" size="3">
<option>First-year student</option>
<option>Sophomore</option>
<option>Junior</option>
<option>Senior</option>
</select>

<p>
If you live on campus, in which residence hall do you reside?<br>
</p>

<select name="housing">
<option>Hamilton Hall</option>
<option>The Woods</option>
<option>Forest Park</option>
</select>

<p>
Comments:<br>
<textarea name="comments" rows="4" cols="25" wrap="virtual"></textarea>
</p>

<p>
<input type="submit" value="Send Results"> <input type="reset">
</p>

</form>

Note that the name attribute of each <input> tag corresponds to what you previously put in each square bracket in the template. These must match exactly. Only use lowercase letters and no spaces or special characters (e.g. - !, &, *).

The action attribute of the <form> tag is split into two parts. If you are using a form in your personal UNIX directory, the form action line would be as follows:

<form method="post" action="http://www.wright.edu/cgibin/cgifile/~e-mail.name/sample_form.txt">

Notice that the first part of the pathname refers to the cgifile program. The second part refers to the location of your e-mail template relative to the Web server (www.wright.edu).

If you are using a form on a departmental Web site, the second part of the action line would be the server relative path to your text template file. separator

Once the user submits the form, he/she will receive a confirmation of what was submitted. Cgifile will show the user the line of information that was appended to "incoming.txt".

The following information was written:

John | Doe | Male | Student | First-year student | Forest Park | Hello world!

cgiemail 1.6

This looks very bland, but is an easy way of letting the user know that the information was submitted successfully.

If you don't want the user to see this simple "success" page, you can place an additional line into your form and make a separate Web page load once the user has submitted his/her information. To do this add the following in your HTML form, somewhere between the beginning and end of the form.

<input type="hidden" name="success" value="http://www.wright.edu/~yourname/success.html">

The URL in "value" can point to any Web page you prefer. Test the sample form to see a sample "success page".

separator

Step 3: Post Your HTML Form and Text Template to the Web Server

After you post your HTML form and text template to the Web server, test the form by filling out and submitting it a few times. Try to vary your responses and attempt to anticipate any mistakes your intended audience may make.

Further information on the cgifile program is located online at http://www.sfsu.edu/training/cgifile/cgifile.htm

separator

Step 4: Importing Results into a MS Access Database

When you are ready to take the data obtained from your form and sort the results, you must first download the "incoming.txt" file. The following instructions will explain how to take your form data and create a simple database in Microsoft Access.

  1. To begin, open Access, select the Blank Database option, and then click OK.
  2. Choose the name and location of the database you wish to create, and then click Create.
  3. Next you must import the data from incoming.txt. Start the process by choosing File, Get External Data, and then Import.
  4. Change Files of type: to Text Files, navigate to the location of incoming.txt, and then select the file. Click Import. Your results should be shown in a crude form in the new window.
  5. Select Delimited as your format of choice.
  6. Choose Next and then select the delimiter you used in your template to separate the submission fields.
  7. Click Next again.
  8. Choose New Table and then click Next.
  9. You can now give each of your fields a specific name. Then click Next.
  10. Let Access add Primary Key and click Next once more.
  11. Name the table you're importing and click Finish.


[ Web Services | Communications & Marketing | WSU Home ]