Using CGI to integrate databases on the Web

Posted on 2000-05-08
Last Modified: 2013-12-25
Can anyone explain to me exactly how CGI scripts are used to integrate databases on the Internet? Where are the CGI scripts stored? How are they invoked. are they embedded in HTML? Is this a good method to choose for integrating your database on the web?
Question by:paulinebelford
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 16

Accepted Solution

maneshr earned 100 total points
ID: 2790401

Q) Can anyone explain to me exactly how CGI scripts are used to integrate databases on the Internet?

A) Chek out this URL. it will answer all your DB questions and then some more!!.

Q) What is CGI?

A) The Common Gateway Interface, or CGI, is a standard for external
gateway programs to interface with information servers such as HTTP servers.
A plain HTML document that the Web daemon retrieves is static,
which means it exists in a constant state: a text file that doesn't change.
A CGI program, on the other hand, is executed in real-time, so that it
can output dynamic information.

Q) Do I have to call it *.cgi? *.pl?

A) Maybe.   It depends on your server installation.

These types of filenames are commonly used conventions - no more.
It is up to the server administrator whether or not CGI scripts are
enabled, and (if so) what conventions tell the server to run or
to print them.

If you are running your own server, read the manual.
If you're on ISP or other rented webspace, check their webpages for
information or FAQs.   As a last resort, ask the server administrator.

CGI is just a protocol, a formal agreement between a web server and a separate program. The server encodes the client's form
input data, and the CGI program decodes the form and generates output. The protocol says nothing regarding which language
the program must be written in; programs and scripts that obey the CGI protocol have been written in C, shell, Rexx, C++,
VMS DCL, Smalltalk, Tcl, Python, and (of course) Perl.

The full CGI specification lays out which environment variables hold which data (such as form input parameters) and how it's all
encoded. In theory, it should be easy to follow the protocol to decode the input, but in practice, it is surprisingly tricky to get

CGI scripts are called in two main ways, referred to as methods  - but don't confuse HTTP methods with Perl object methods!
The HTTP GET method is used in document retrievals where an identical request will produce an identical result, such as a
dictionary lookup. A GET stores form data in the URL. This means it can be conveniently bookmarked for canned requests,
but has limitations on the total size of the data requested. The HTTP POST method sends form data separate from the request.
It has no such size limitations, but cannot be bookmarked. Forms that update information on the server, like mailing in feedback
or modifying a database entry, should use POST. Client browsers and intervening proxies are free to cache and refresh the
results of GET requests behind your back, but they may not cache POST requests. GET is only safe for short read-only
requests, whereas POST is safe for forms of any size, as well as for updates and feedback responses. Therefore, by default,
the CGI module uses POST for all forms it generates

Simplest CGI Program

Here's the source code for your first CGI program; it's so simple, it doesn't even need to use the module:

#!/usr/bin/perl -w
# howdy--the easiest of CGI programs
print <<END_of_Multiline_Text;
Content-type: text/html
    <TITLE>Hello World</TITLE>
    <H1>Greetings, Terrans!</H1>


Author Comment

ID: 2791620
Thank you for your help. That web site has an overwhelming amount of information (!) but I am less confused now :)

LVL 16

Expert Comment

ID: 2792435
Glad to know that you find the info userful.

one last piece of advice. i would suggest that while you are going thru the info on the web-site, if you find any piece/section confusing/difficult to understand, just skip it and move on.

once you have a good understanding of the concept, you can revisit that peice/section and i am sure you will find it a piece of cake!!

Wish you all the best.


Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question