• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

How Scripts Work

Although creating detailed CGI scripts can get complicated, the basic theory behind what’s going on isn’t that tough to understand. Scripts are designed to accept data and/or generate HTML documents in response. It all begins when the script is called, via an URL, often as the action of a <form> element. When the server notes this call, it locates the script in the cgi-bin directory and tells that script to execute. The script then checks the method used to send the data (if any) and then retrieves that data. The script begins to cull through that data looking for important information. When it finds what it’s looking for, it computes, stores, or does whatever else it needs to with that data. Then, in most cases, it returns an HTML document to the user’s browser, with the results of the computation, a thank-you page, or something similar.

Scripts can also be called directly, without a <form> acting as the intermediary. Instead, the script might be part of a hyperlink, or it might even be the URL in an <img> element. When that happens, it’s often designed to either launch a very simple script or a complex one. A fairly simple script might be one that returns a “quote of the day,” a random number, or a page counter. A very complex script might be responsible for an entire Web application, such as those used to take online merchandise orders or manage travel reservations.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint