COM 354: Web Design Basics Banner
COM 354 SyllabusCOM 354 Class ScheduleCOM 354 Reading listCOM 354 Course topicsCOM 354 GradesCOM 354 Opening page

Using CGI Script to process the form data

Creating a form using Dreamweaver is easy. But when a user enters the information and clicks the 'submit' button, what happens to the information?

It is being sent back to the server but shouldn't the server know how to handle that information? We have to provide instructions to the server on what we want it to do with the information.

The most commonly used program to provide form processing instructions to the server is written in a format known as CGI (Common Gateway Interface). It is something that computer programmers learn. For the rest of us humans at WMU, there is an easier solution. Office of Information Technology has developed an appropriate CGI script to process form data on WMU servers and it is called gform.

There are two main ways data can be handled using gform.

    1. The information that the user enters into the form is emailed to a designated email address.
    2. The information is stored in the server. Whenever, another user fills out the form and submits data, it is appended after the first poster's information.

The easiest of the two is the first. So let us go through the steps enter the server instructions to process the form data.

Step 1: In the action box of the form, enter /cgi-bin/gform.

Step 2: After creating the form in Dreamweaver, go to the HTML version of the document. Locate the <form> and </form> tags and all that goes in between.

Place the cursor after the </form> tag and enter gform instructions. The instructions will depend upon the number of variables in your form. For each variable you require to enter one line of instruction. Finally, a command to deliver the information to a designated email address.

See a simple example below:

<form name="My form" method="post" action="/cgi-bin/gform">
<p>Your name:
<input name="name" type="text" id="name"> //this is the first variable
Your Email address:
<input name="email" type="text"> // this is the second variable
</p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>

<!--gform "Form submitted by: $(name)\n"--> // this line for 'name' variable.

<!--gform "The date is $(date) and the time is $(time)\n"-->

<!--gform "Email address: $(email)\n"--> // this line for 'email' variable

<!--gform deliver=mail "kayany@wmich.edu" subject="Email newsletter"-->

This last line instructs the server to email the information to me.

 

If you want to learn more features of gform, check out the page on gform on WMU's server.

Warning: GFORM is not a userfriendly program

Honestly, gform is not a very userfriendly program. A couple of lessons that I was taught while struggling with the program are the following:

    1. Dreamweaver tends to indent the gform tags. But gform program will process commands only if they are left aligned.
    2. While saving the HTML file with the form, do not go with the default ending .htm but save it with the .html ending.
    3. Make sure that every space and quote is in place. Good luck.

 

| Syllabus | Schedule | Readings | Topics | Grades | Home | Email me |
© Joseph Kayany, School of Communication, Western Michigan University
Kalamazoo, Michigan, USA.
November 17, 2006