Wright State University Home PageWSU Internet Resources

cgiemail

The cgiemail program, located on the main web server, provides Form-to-Email processing. You can create an HTML (Web) form that sends the form information to you in an e-mail message.

Refer to http://www.wright.edu/cwis/workshop/formcwis.html to see a working example of a form using the cgiemail program.

separator

Step 1: Create Your cgiemail Template

Before you start receiving e-mail messages through the Web, you must create a template to format the information that will be provided through the Web form. Create a text template similar to below.

to: your.e-mailaddress@wright.edu
Subject: form sample
Insert blank line here
First name [firstname]
Last name [lastname]
gender [gender]
student [student]
parent [parent]
alumni [alumni]
class [class]
housing hall [housing]
comments [comments]

For the first column of your template, use common names or words that describe the corresponding form field. When the form is processed by the server, this column will appear in the output e-mail exactly as within your template file.

For the second column, use the same value as the field's name property (but surrounded by brackets) as you do within your HTML file. This value must be one word and can contain no spaces or special characters. These words must match exactly for the form to process correctly. When the form is processed by the server, these words will be replaced by the values of your form field's names.

Note: The template's first line must be "to: your e-mail address"
Note: Be sure to insert a blank line between the header lines and the body.

Note: Save the file as ASCII text.

Now you are ready to create the HTML form.

separator

Instructions for using cgiemail with FrontPage 2000 are located at:.

http://www.wright.edu/web/resources/fpforms.html

separator

Step 2: Create the Form

Example:

<form action="http://www.wright.edu/cgibin/cgiemail/cwis/workshop/formcwis.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="checkbox" name="student"> Student 
<input type="checkbox" name="parent"> Parent
<input type="checkbox" name="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 email"> <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 e-mail 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. 

Notice that the first part of the pathname refers to the cgiemail 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.

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/cgiemail/~e-mail.name/sample_form.txt"> separator

Once the user submits the form, he/she will receive a confirmation of what was sent.

    to: your.e-mailaddress@wright.edu
    Subject: form sample
     
    First name Daffy
    Last name Duck
    gender Male
    student on
    parent
    alumni
    class
    housing hall The Woods
    comments Here we go a hunting ...

separator

The e-mail message you receive looks very similar ...

    Subject: form sample
    Date: Sat, 01 Jan 2000 09:10:52 -0400
    From: form Nobody
    To: your.e-mailaddress@wright.edu

    First name Daffy
    Last name Duck
    gender Male
    student on
    parent
    alumni  
    class  
    housing hall The Woods
    comments Here we go a hunting ...

Note: The e-mail message will be from "nobody," so be sure to include an e-mail field on your form if you need to respond by e-mail!

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 cgiemail program is located online at http://web.mit.edu/wwwdev/cgiemail/webmaster.html