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.
Caution |
Some browsers have also supported what is commonly referred to as a mailto form, which uses a mailto e-mail address (<mailto:yourname@yourdomain.com>, 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. |
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="http://www.yourhost.com/ cgi-bin/sendmail.pl"> <input type=hidden name="to" value="yourname@yourhost.com"> <input type=hidden name="return-url" value="http://yourhost.com/yourname/confirm.html">
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.
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:
The CGI Resource Index at cgi.resourceindex.com/Remotely_Hosted/Form_Processing/
FIND IT ONLINE
CGIexpo.com at www.cgiexpo.com/Scripts/134_Remotely_Hosted_Mail_Management_Mail_Forms/
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.
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:
FIND IT ONLINE
The CGI Resource Index at cgi.resourceindex.com/—You can find their list of form-processing CGI scripts at cgi.resourceindex.com/Programs_and_Scripts/Perl/Form_Processing/
ScriptSearch at www.scriptsearch.com/—Bills itself as the world's largest CGI library. You can find their list of form-processing CGI scripts (written in Perl) at www.scriptsearch.com/Perl/Scripts_and_Programs/Form_Processing/
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 sendmail.pl, will set read/write/execute privileges for the owner (yourself), but only read/execute (but not write) privileges for anyone else, for a send-mail.pl CGI script.
There are also a number of low-cost form-creation software programs that create CGI scripts for you:
FIND IT ONLINE
WebForms by Q&D Software at www.q-d.com/—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 www.webgenie.com/—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 www.munica.com/ (Windows)—Includes an HTML form editor, database administration tool, query builder, FTP script installer, and easy-to-use script templates.
HTML Gorm at surf.to/aap/ (Macintosh)—This is a freeware form-creation software tool.