support > doing more > web site maintenance > using CGI email
cgiemail forms are great for collecting specific information from individuals visiting your Web site. These instructions will explain how to create a form on your own Web site so that others can send email messages (or information) to you through a Web interface. The following instructions assume a basic understanding of HTML and FTP. The explanation is based on the form seen in the example below.Form Example
Creating your Own Forms
Creating forms with cgiemail is a two step process. First we'll insert the HTML code using the <form> tag into your Web page to create the form. Next, we will create a text document (called a template) and place it in your Web directory. Creating the HTML:The code for the form must be created using the <form> tag. This code is inserted into your HTML document in the location where you want the form to appear on the page. The code in blue below will create the form example above. Note: Be sure to leave out the ~username for corporate Web sites. <form method = "post" action="/cgi-bin/cgiemail/~username/helpform.txt">Creating a Text Template:
Name: <input name="name" /><br />
Email Address: <input name="required-email" /><br />
Favorite Color: <input name="color" /><br />
Comments:<br />
<textarea cols="50" rows="8" input name="comments" /></textarea ><br />
<input type="submit" value="Send" /> <input type="reset" value="Clear" />
</form> Note the ~username would be your own username and that the name of the Text Template, in this case helpform.txt, must match the specific template we will create in Part II. The rest of the code can be tweaked to your liking. For example, you could change the size of the form window by changing the textarea cols="50" rows="8" values. Or, you could change the text on the value="Send" and value="Clear" buttons.
Now we will create a short Text Template which will interact with the form inputs. You can use Notepad if you are a Windows user or Simpletext if you are using a Macintosh. For demonstration purposes, our form is called helpform.txt. You have seen this document name referred to in the HTML code in Part I; (<form method = "post" action="/cgi-bin/cgiemail/~username/helpform.txt" >). The Text Template will be as follows: To: help@indra.com
From: [required-email]
Subject: Web Page Contact Name: [name]
Email Address: [required-email]
Favorite Color: [color]
Comments: [comments] Note that the top line should have the email address where you wish the form to be sent. For these forms to work properly, a few rules must be followed:
- The first line of your Text Template should always be the To: line.
- The text that appears in the input name="", must match the text in brackets in the Text Template. So, if the HTML code reads, Food: <input name="foodname" />, the corresponding line on the Text Template should read Food: [foodname]. If these do not match, the form will not work.
- The path specified in the <form> code must point to the exact location of the Text Template. For example, if your Text Template called helpform.txt is in the top level of your Web directory, your <form> tag will look like this: <form method = "post" action="/cgi-bin/cgiemail/~username/helpform.txt">. If you place helpform.txt in a folder called onlineform, your <form> tag will look like this: <form method = "post" action="/cgi-bin/cgiemail/~username/onlineform/helpform.txt">.
- You should always require the email field to guarantee that you have somewhere to reply to. To require any field, simply use "required-" in front of the variable.
You can test your forms by sending email to yourself. Cgiemail will either give a confirmation that the email was sent or an error message telling why the email failed. The most common errors involve mismatching the name of the Text Template and/or uploading the text template to the wrong directory.
For more information visit the cgiemail Home Page.
If you have any questions or need assistance, please contact us. Back to top