|
|
Creating Web Forms Using cgiemailThere are two ways to create a cgiemail web form.
What is cgiemail?Usually, creating web forms involves writing a complicated form processing
script (cgi) that makes the form work. cgiemail simplifies this considerably.
Instead of writing cgi script, all you need to do is write a text file.
The next section describes what needs to be included in this text file.
The Text File:The first step in using cgiemail is creating a text file. This file will be used as a template for the email that the form sends. Important: This file should be created in Notepad or a similar text editor program. Before making the text file, you must know what information the form will collect. The form, "example.txt" (shown in the paragraph below below), will be used throughout this document as an example. This form will be used to collect the following data: name, email, gender, and favorite color. A text file needs to include header lines, a blank line, and a body.
To create a text file such as example.txt:
The Form:The next step is building the form. Here is what the form will look like: The HTML Code Used to Produce the FormTo make the above form, HTML tags must be added to the source of the page
directly after the <BODY> tag. Below is an example of how the HTML would look:
Form Method<FORM METHOD = "POST" ACTION = "http://web.indstate.edu/cgi-bin/cgiemail/it/user-serv/websupport/example.txt"> This is the first HTML tag that should be added. It directs the form to the location of the text file. Notice that the address seems longer. The actual location of the text file is "http://web.indstate.edu/it/user-serv/websupport/example.txt". In order for the script to work, the "/cgi-bin/cgiemail/" must be added after the address of the web server but before the subdirectory path on the server. Note: The example above works for web.indstate.edu; the
exact address may vary depending on your server and the location of your
file within the subdirectories.
Text InputText inputs need to be added for Name and Email. The format used is: <INPUT NAME = "variable name" size = "number of spaces"> Replace variable name with the name used in the text file. Replace
number
of spaces with the length wanted for the input. The length used above
is 20. The source for Name and Email (without any formatting tags)
should look like this:
Radio ButtonsFor Gender, radio buttons are used. The format used is: <INPUT TYPE = "RADIO" NAME = "variable name" value = "value to give variable"> Replace variable name with the name used in the text file.
Replace value to give variable with the value the variable would
have if this button were checked. There are two choices here so there should
be two tags added. Since they are both dealing with the same variable,
the name should be the same. Only the values are different.
The source, without formatting, should look like this:
Drop-Down MenuFor Favorite Color, a drop-down menu is used. The format used is:
Replace variable name with the name used in the text file. Replace choice with the color names. The option tag can be used as many times as need between the select tags. Here is what the source should look like: Favorite Color:
Submit ButtonA submit button is needed. When the user clicks submit, it sends the email. The source for a submit button looks like this: <INPUT TYPE = "SUBMIT" VALUE = "Submit">
Uploading the Files:After both the text file and the form are made, they both need to be uploaded.
It is important that the text file is uploaded into the location that appears
in the source of the form. In this example recall that: ACTION="http://web.indstate.edu/cgi-bin/cgiemail/it/user-sev/websupport/example.txt"
The Working Form:Now the form should work. After the user fills out the form and clicks the submit button, all the variables will be given their values and the web browser will display a message showing that the mail has been sent. The message should be similar to this one: The following message was sent.
cgiemail link:
|
||||||||||||||||||
This page is maintained by web@indstate.edu |