![]() |
CGI Introduction Program![]() ![]() ![]() ![]() ![]()
You begin with the traditional introductory programming problem. You want to write a program that will display " Hello, world! " on your Web browser. Before you can write this program, you must understand what information the Web browser expects to receive from CG I programs.
You also need to know how to run this program so you can see it in action.
The "Hello, world!" program looks like
Save this program as hello.cgi, and install it in the appropriate place. For most people, the proper directory is called cgi bin. Now, call the program from your Web browser, For most people, this means opening the following Uniform Resource Locator (URL):
http://hostname/directoryname/hello.cgi
There are couple of things worth mentioning about hello.cgi. First, you're using simple print commands. CG I programs do not require any special file handles or descriptors for output. In order to send output to the browser, simply print to the stdout. Secondly, notice that the content of the first print statement (Content Type'. text/ html) does not show up on your Web browser. You can send whatever information you want back to the browser (an HTML page or graphics or sound), but first, you need to tell the browser what type of data you're sending it. This line tells the browser what sort of information to expect; in this case, an HTML page. Third, the program is called hello.cgi. It's not always necessary to use the extension cgi with your CGI program name. Although the source code for many languages also use extensions, the cgi extension is not being used to denote language type, but is a way for the server to identify the file as an executable rather than a graphic file or HTML or text file. Servers are often configured to try to run those files which have this extension, displaying the Content all others. Although it might not be necessary to use the cgi extension good practice.
|
|
CGI
Advantages of CGI
How CGI Works
Compiled Versus Interpreted
Input to CGI
CGI Introduction Program
HTML Forms
Accepting Input from the Browser
CGI Environment Variables
Get Versus Post Method
Get Method
Post Method
Sample <FORM> Based CGI Program
Complete Example for <FORM>
Output from CGI
Header and Body:Anatomy of Server Response
HTTP Headers
Carriage Returns and Newlines
Formatting Output CGI Common MIME TypesLocation Header Useful HTTP Stautus Codes Other Headers Dynamic Pages Sending Images Displaying the Current Date Feedback Form Program Server Side Includes Server Side Include Environment Variables Displaying the Date with Date Counter Example of SSI Counting the Number of Accesses Better Approach Towards CGI Program Client Versus Server Accessing a HTML Document Submitting a Form Accessing a CGI Program Databases ODBC Creating a DSN Win32::ODBC Module Creating a Table Inserting Data into a Table Deleting Data from a Table
Updating Data in a Table
Selecting Data from a Table Operating Systems Security Securing Your Web Server Writing Secure CGI ProgramWeb DesignDomain Names Home
FAQ
My Account
IP Address
SSL Certificates DNSWeb Hosting Web Server Cheap Web Design Dedicated web hosting Managed web hostingE Commerce Principles of E-Commerce E-Banking Electronic Payment System E-Security Credit Cards Smart Cards
The Mailbox POP Server SMTP Server IMAP Protocol |
| Home | Web Hosting | Web Design | Sitemap |
| Copyright (C) 2007. Web Domain design hosting. All rights reserved. |