|
|
Building a two-way Web |
|
What’s CGI?CGI means Common Gateway Interface. A gateway provides data or software access for “outside” computers which may use a different “platform” [operating system and software applications] or different data formats than those behind the gateway. [Hotmail, functioning as a bridge between Web and e-mail, is perhaps the world’s best-known gateway.] In CGI, a process linked to the Web server retrieves or creates data on behalf of visitors to a Web page, who receive tailored content through their ordinary Web browser. [More details and comparison to PHP] What’s cool about CGI?Things behave the same from the user’s point of view regardless of what type of browser is used (kids, don’t try this with JavaScript) because of the Common Interface for presenting data across the boundaries between the various pieces of software. With appropriate “glue” software, the same CGI script can run happily on a variety of Web server platforms as well ... and the details of the code remain hidden from prying eyes (again, unlike JavaScript). What can I do with it?Following are some of the most popular CGI applications (and the data flows happening behind the scenes to make them work). |
|
|
|
|
|
|
|
|
|
|
|
It’s also possible to echo several recent submissions on the response page, in which case we have a guest book (or, if the messages are organized into “threads,” a web board). |
|
|
Serving an image involves sending a raw binary file preceded by plain-text HTTP header information. Webmasters resort to some interesting tricks to fool the server into complying. |
|
How do I put it on my page?The easiest way to add a routine capability like a counter or a guestbook is to find someone who’ll let you share a CGI s/he has running already. Asking the same outfit that’s hosting your pages could get you quickly to an adequate solution (and it gives you leverage on support/uptime issues), but there’s no rule against arranging use of a third-party server if it offers what you need. Either way, just a line or two of HTML (handed to you as part of the deal) gets you rolling, and someone else even pays for the bandwidth :) |
|
Advanced projects (like protecting images or passwords from
unauthorized use), or unusually daring attitude on your part, may
call for installing and running your own CGI. Your server admin
may not go along with this plan (a poorly written script
can open major security holes, as well as bogging down the
several dozen sites besides yours that live on the same box),
but if s/he does, you’ll save yourself a lot of grief by getting
a ready-made (and battle-tested) script from a site like
WDVL.
Or as a last resort, take a few days out and start learning
Perl.I haven’t ventured to write an in-depth companion to this page (CGI 102?) because several other Web sites already cover the territory so well. Read all those I recommended, if you have time; each one seems to reveal a trick or two the others overlooked. |
Copyright ©2000-2006
by MaXHaX. Content from this page
and other pages in same directory
may be freely shared if unaltered and this copyright
notice is included.
|