- Version
- Download 23
- File Size 5.34 MB
- File Count 1
- Create Date January 1, 2020
- Last Updated February 3, 2020
Education for all
What is CGI programming anyway? What is the BIG DEAL?? And why the heck is it called a gateway?
Very good questions. Ones that bugged me early on and ones that still seem to get asked quite frequently.
CGI programming involves designing and writing programs that receive their starting commands from a Web page—usually, a Web page that uses an HTML form to initiate the CGI program. The HTML form has become the method of choice for sending data across the Net because of the ease of setting up a user interface using the HTML Form and Input tags. With the HTML form, you can set up input windows, pull-down menus, checkboxes, radio buttons, and more with very little effort. In addition, the data from all these various data-entry methods is formatted automatically and sent for you when you use the HTML form. You will learn about the details of using the HTML form in Chapters 4, “Using Forms to Gather and Send Data,” and 5, “Decoding Data Sent to Your CGI Program.”
CGI programs don’t have to be started by a Web page, however. They can be started as the result of a Server Side Include execution command (covered in detail in Chapter 3, “Using Server Side Include Commands”). You even can start a CGI program from the command line. But a CGI program started from the command line probably will not act the way you expect or designed it to act. Why is that? Well, a CGI program runs under a unique environment. The WWW server that started your CGI program creates some special information for your CGI program and it expects some special responses back from your CGI program.
Before your CGI program is initiated, the WWW server already has created a special processing environment for your CGI program in which to operate. That environment includes translating all the incoming HTTP request headers (covered in Chapter 2, “Understanding How the Server and Browser Communicate”) into environment variables
(covered in Chapter 6, “Using Environment Variables in Your Programs”) that your CGI program can use for all kinds of valuable information. In addition to system information, like the current date, is information about who is calling your CGI program, where your program is being called from, and possibly even state information to help you keep track of a single Web visitor’s actions. (State information is anything that keeps track of what your program did the last time it was called.)