Microsoft KB Archive/205691

{|
 * width="100%"|

FP2000: How to Call a Custom CGI Script With a FrontPage Form

 * }

ID: Q205691

-

The information in this article applies to:


 * Microsoft FrontPage 2000

-

'''*** WARNING **** *** WARNING **** *** WARNING **** *** WARNING ****

This article is information for Support Professionals. In no way is this suggesting that you (the Support Professional) write, debug, interpret, or configure a customer's CGI script/program, command interpreter, or Web server. This article is meant to be educational. As a support professional, your boundary for custom CGI is showing the customer how to use the FrontPage interface for directing form output to the CGI program.


 * WARNING **** *** WARNING **** *** WARNING **** *** WARNING ****'''

SUMMARY
This article explains the functionality of Common Gateway Interface (CGI) and how to use a custom CGI script as a form handler.

NOTE: Not every script uses parameters in the same manner. For example, a script may use specific methods to obtain parameters. If the customer is unaware of these methods, direct the customer to the author of the script.

MORE INFORMATION
You will need the following script to complete the steps in this article:

"http://www.speakeasy.org/~cgires/web2mail/#download"

Overview
It is first important to understand what HTML forms and CGI scripts are. Although they are very different, they work closely together. A form is a web page with some additional markup tags that instruct a web browser how to display the various form elements, such as check boxes, drop-down lists, command buttons and text boxes. However, the web page itself does not process the data, nor does the web server. In fact, the Web server does not know what you want to do with the submitter's answers. A separate program or script, must process that data, in whatever way you want.

HTML forms are just markup tags on a web page. The browser sends the information gathered by the forms via HTTP to the server. The server uses CGI to pass the values to the script or program.

NOTE: CGI programs and scripts can be written in a variety of different languages, such as PERL, TCL, C, and shell scripts. Regardless of which language is used, the FrontPage interface is the same.

When the submitter submits a form, the browser bundles the answers and sends them to the web server. The Web server passes this information to your script for processing. The CGI script knows how to read that bundle of data. Here are some important points about CGI:


 * 1) The web page itself does not process the data entered on the form. Neither does the web server. The script instructs the Web server to send the data to it. It speaks the CGI language that the server uses to send the data. You need both the web page and the script.
 * 2) For security reasons, many web servers will not execute a file (even a script or program with the right permissions) unless it is in a designated directory or has a designated file name extension. This is configured by the server administrator.

NOTE: The customer MUST already know the following information:


 * 1) Is the web server configured for CGI?
 * 2) What directory do you put the script in?
 * 3) What extension is used by the script (for example, .cgi or .pl)
 * 4) Do they have the correct permissions to use CGI and to execute scripts?
 * 5) Where is the HTTP location of the script? This is important when you use a CGI script as a Form handler.

If the customer does not know this information, refer them to the server administrator, Internet Service Provider, or Web Presence Provider.
 * 1) What are the parameters you want to pass to the script? And what method do you want to use (for example, QueryStrings vs. hidden form fields)?
 * 2) What language do you want to use for the CGI (for example, PERL 4/5, C, or TCL)?

If the customer does not know this information, refer them to the author of the script. If the customer is the author of the script, refer them to Developer Consulting for $195 per hour.

Installing a CGI Script
Each server is configured a little differently. The customer should ask their system administrator if CGI is enabled on the server. If the customer is the system administrator, he should read the documentation to determine this. The customer should also determine if user-installed CGI scripts are permitted. Some systems permit only the administrator to install CGI scripts. Then you will typically need to find out the following:


 * 1) What is the path to the command interpreter? (This information is needed for the first line of a CGI script NOT for the HTML.)
 * 2) Where do you need to place the script?
 * 3) What do you need to call the script?
 * 4) What permissions do you need to set for the script and does the script need to write to some files?
 * 5) How do you set those file permissions?

Building a Form in FrontPage
 Create a new page in FrontPage. On the Insert menu, point to Form, and click One-Line Text Box. Insert three more text boxes on the page.

You should now have four text boxes. You can now incorporate a CGI Form handler to use the FrontPage generated form. Right-click the form and click Form Properties on the menu that appears. From the Send To Other list, click "Custom ISAPI, NSAPI, CGI or ASP Script." Click Options. In the Options dialog box, do the following:

  In the Action box, type the following URL: "http://www.speakeasy.org/~cgires/perl_form.cgi" In the Method box, click Post.</li> Click OK.</li></ol> </li> Click OK.</li> Save the page as an HTML page.</li> On the File menu, click Preview In Browser.

NOTE: After you click Submit on the form, a page called A Web Form Analyzer will appear. This is the results page of the CGI script.</li></ol>