information coming from the client. PERL gives you
an access to this variable. Therefore you start your
CGI program by extracting this information.
Remote user's IP address REMOTE_ADDR String in URL after the ? character QUERY_STRING Type of Browser viewer is using. HTTP_USER_AGENT Number of characters submitted from a POST command CONTENT_LENGTH What it Gets Name
Database Connection In PERL
You can use two ways to access a database from a PERL program.
Using ODBC is currently supported by every major software company in the world.
In this tutorial, MS Access will be used. Yet it will still be the same with ODBC whether you connect to MSACESS, DB2, or any other database.
Database Connection In PERL (Continued)
Steps of connecting to a database.
STEP 1: Identify the database drivers you have on you system.
STEP 2: Create your database created.
STEP 3: Create DSN (Date Source Name) for your database. You can do that graphically form the “CONTROL PANNEL”, or through programming .
STEP 4: Connect to the database using the Win32::ODBC module.
CGI Program Examples
Suppose you have a database. You want to connect to it. What we should do is to create first a DSN. Then you need to connect to the database. Once you are connected, you can make query to the database using SQL statement. So let’s do that.
Suppose that we have a couple of listservs that we want our user to be able to subscribe or unsubscribe to. We want to create first a GUI interface (Using HTML form) that will take the the user information and send it back to the cgi program which in turn will send subscription or un-subscription to the listserv on behalf of the user.