Developing forms using
(see also CSUN cgi-email page)
This guide will help you write a WWW form that sends an e-mail message to you. The following steps are required.
- Create an e-mail template.
- Upload e-mail template as text file
- Create the HTML form.
- Make sure the ACTION is correct.
Before you start receiving e-mail messages through the web, you should decide what these messages should look like. Create an ASCII file, called an e-mail template, that looks something like this:
Subject: Computer Service Request
EMAIL FROM: [email]
- Wherever you want the user of your form to supply information, use a single word inside square brackets with no spaces, e.g. Your name: [yourname]. Not [Put your name here.].
- Line three should be blank, but no others should be blank.
2. Upload e-mail template as text file
- Save your email template as a text file with the file extension name .txt.
- Upload this text file into your account. Take note of the location of this file as it will need it below. In this example the file is uploladed to www.csun.edu/~vceed002/courses/619/report.txt
- If you created the file on a Mac, be sure to upload it as text. (Unix computers have different codes denoting the end of a line than Mac's do, so your file might look like one long line to the Unix computer.) Note: if you do not upload as text, you will get an Internal Server Error when trying to use the form.
Here is an sample form that correponds to the email text file above.:
4. Set the ACTION in html
View the html in your web page (source code).
For the example above it will look something like this:
- <form method="POST">
- <p><input type="text" size="32" name="email">Please enter your email.</p>
- <p><input type="text" size="32" name="tag">Please enter the tag number of the computer.</p>
- <p><textarea name="problem" rows="3" cols="39"></textarea> Please describe the problem.</p>
- <p><input type="submit" name="B1" value="Submit"></p>
Find the html that starts the form command and insert the path to the file, including the cgi-bin script for the server that you are using, usin gthe action command:
- <form action="http://www.csun.edu/cgi-bin/cgiemail/~vceed002/courses/619/report.txt"
On the CSUN server, the script is : cgi-bin/cgiemail. the
The blue text om the action comand indicates the path to the email text file. Note that the cgi-emai scrpit has been inserted after the server, but before the account. "http://www.csun.edu/cgi-bin/cgiemail/~vceed002/courses/619/report.txt"
To learn to create more complicated forms, read NCSA's guide. For now, simply note that the NAME of each input corresponds to what you previously put in the e-mail template. In this example they are email, tag, problem