JavaScript EditorDebugger script     Dhtml css 

Team LiB
Previous Section Next Section

Creating CGI Forms

To implement a CGI form on your Web site, you need to have access to a form-processing CGI script, either provided by your Web host on your site's Web server or by a third party on their Web server.


Some browsers have also supported what is commonly referred to as a mailto form, which uses a mailto e-mail address (<>, for instance) as the ACTION attribute value. This kind of form was initially introduced in the Netscape browsers. Internet Explorer 4 and 5 also supported mailto forms, but only if a user's browser was properly configured. No current browsers, however, support using mailto forms (including Netscape 7). For that reason, only CGI forms should be published to the Web.

Using Your Web Host's Form-Processing Script

Your Web hosting company might provide a generic form-processing script that you can use to process your own CGI forms. If so, this is the simplest solution. All you generally have to do is point your form to the location of the form-processing CGI script, as well as include any hidden controls that might be required by the script to specify where you want the form responses sent and which page you want to be displayed as your confirmation page after the response has been successfully sent. Here's a fictitious example of what the start of your form might look like:

<form method="post" action="
<input type=hidden name="to" value="">
<input type=hidden name="return-url"

Some form-processing CGI scripts require that you include the e-mail address you want to send form responses to as a hidden control (as shown in the example above). As with including a mailto e-mail link to your page, this can expose your e-mail address to being harvested by spambots. One workaround is to sign up for a free Web-mail address and use it for gathering form responses. Then if that address starts to get inordinately spammed, you just need to get a new Web-mail address. You can also install a form-processing CGI script that does not require that you expose your e-mail address.

If a Web host provides a form-processing CGI script, they usually do so by installing it in a personal cgi-bin folder that is available only to the Web site owner. This folder is normally located in the account holder's root folder (which is usually one folder up from the Web site's root folder). For more specific information on the exact codes you'll need to include in your HTML form and any configuration steps you might need to take to implement CGI forms in your site, contact your Web hosting company's technical support.

Using a Remotely Hosted Form-Processing Script

If your Web host does not provide access to a form-processing CGI script, there are a number of services available on the Web that let you use their form-processing CGI script to process your forms. This can be an easy way to add a CGI form to a site, since you normally don't have to do anything other than insert the appropriate codes in your form. These remote form-processing services are usually free to you, but generally display advertising on the confirmation page that is displayed after a form is submitted. Even if that is not appropriate to the site you're creating (your company might not want other companies' advertising to be generated from their site, for example), you can still use a remotely hosted form-processing script to test out a CGI form on your own local computer.

For lists of services offering access to remotely hosted form-processing CGI scripts, see the following resources on the Web:

Installing Your Own Form-Processing CGI Script

If your Web host does not provide a form-processing CGI script that you can use to forward form responses, they may allow you to install and configure such a script on your own. To be able to do this, your Web host has to allow you to install and configure "custom" CGI scripts in your own personal cgi-bin folder. Many free Web hosting services do not offer this capability, however.

Sources of Form-Processing CGI Scripts

If you are allowed to install and configure custom CGI scripts, you can find many sources on the Web that offer form processing and other CGI scripts that you can install. Here a couple of the best:

Possible Requirements for Installing CGI Scripts

If you want to install and configure your own CGI form-processing script, you should be aware of the following:

  • Your Web host must allow you to install and configure your own (or "custom") CGI scripts for your site. Many free Web hosting services do not allow custom CGI scripts.

  • If installing a CGI script written in Perl, the Perl programming language must be available on your site's server. CGI scripts written in other languages may also require additional server-side support. Besides Perl, other languages that can be used to create CGI scripts include UNIX Shell scripts, PHP, Tool Command Language (TCL), C++, Visual Basic, VBScript, and AppleScript, depending on which OS your Web server is running and which languages are available on it.

  • If your Web site is located on a UNIX server, you may also be required to set access permissions for the form-processing CGI script that will allow outside users (not logged onto your server) to use it. To do this, you need to access your Web site's cgi-bin folder using either an FTP or a Telnet program and use UNIX's Change Mode command to set the privileges for script. For instance, issuing the command, chmod 755, will set read/write/execute privileges for the owner (yourself), but only read/execute (but not write) privileges for anyone else, for a CGI script.

Using Form-Creation Software

There are also a number of low-cost form-creation software programs that create CGI scripts for you:

    WebForms by Q&D Software at—With Web-Forms, you need to use it to create your form, but then you can opt to have it create the form as a Mailto or a CGI form. If you choose to create a CGI form, it creates the CGI script for you.

  • CGI*Star Pro by WebGenie at—With CGI*Star Pro, you just need to specify the form for which you want a CGI script created, and it will then create it for you. Web-Genie also provides a remotely hosted form-processing CGI script that registered users can utilize.

  • FormPal at (Windows)—Includes an HTML form editor, database administration tool, query builder, FTP script installer, and easy-to-use script templates.

  • HTML Gorm at (Macintosh)—This is a freeware form-creation software tool.

Team LiB
Previous Section Next Section

JavaScript EditorDebugger script     Dhtml css