In recent years, Internet and intranet have developed rapidly, and companies have built their own intranet to strengthen the links between the enterprises, promote communication with the external world, and enhance the competitiveness of the enterprise. By building your own Internet server, companies can publish advertisements on the Internet, introducing the company's situation and products, collect customer opinions, and establish virtual electronic shopping malls. Everyone knows that writing an HTML hypertext file is on the World Wide Web server, you can access your homepage through a variety of browsers, but how to make your static home page to respond to customer action and contact your local database, The corresponding content of the database is transmitted to the remote browser? This needs to be contacted through the CGI interface.
The CGI full name is Common Gateway Interface, which is the interface of the WWW server calls the external program through the CGI, the WW W server can do some work in some itself.
The CGI interface is also different under different operating systems, which can be divided into a Standard CGI interface, the DOS CGI interface and the WIN CG I interface, etc. The Standard CGI interface is used for UNIX systems, which enables contact between WWW Server and CGI applications through environment variables. The DOS CGI interface is the same as the STANDARD CGI interface principle. The WIN CGI interface is different from the top. Since more and more WWW Server uses a Windows system, the Windows system does not effectively deliver environment variables, and a Windows CGI standard is proposed by Bob Denny and is constantly promoted.
WIN CGI is linked through .ini file. In a Windows environment, many applications use the .ini file, the profile file to define some basic settings, and between the WIN CGI program and WWW Server are also connected through the Pro File file. When the WWW Client triggers the CGI program via WWW Server, WWW Server actively generates several files in the temporary directory, divided into .ini, .inp, .out and other files. When the WWW Server generates a CGI program, pass the absolute path of the .ini file to the CGI process through the command line parameter. The .ini file also contains .inp, .out and other file path information. This way, the CGI program can read the information provided by the .ini and .inp file, understand all the data from the WWW Server end and the WWW Client side. Then, the CGI program can call an external program or perform the functionality of the external program directly by the CGI, and write information to the client to the HTML text in the form .out file. Finally, WWW Server takes the HTML text of the .out file, transfer the information to the WWW Client side and deletes the files in the temporary directory. So, what data does the CGI's profile file contain? Like Windows Other .ini files, the CGI profile file contains many sessions, each session contains some Key, the following is some of the CGI PROFILE
[CGI] Request method = post // Transfer mode, the form method in HTML has GET, POST, HEAD, etc. Server Software = Website / 1.1e // Server name and version. Server name = 199.199.198.55 // Server IP address. Server port = 80 // Socket Port for Server. Server admin=tomy@vico.bme.zju.edu.cn/server administrator's E-mail address. Referr = http: //199.199.198.55///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wwpread. Remote address = 199.199.198.89 // The IP address of the Client end. [System] Output file = c: /website/cgi-temp/198ws.out/ / The path name of the output file. Content file = c: /website/cgi-temp/198ws.inp/ The path name is entered. [Form Literal] type = b // The received Form Data is the result of the result of the Client side action.
In principle, you can use the language of the CGI program: Perl, Applescript, UNIX Shell, VB, C / C , etc. But in the Windows (NT, 3X, 95) environment, you must also write a delicate WIN CGI program with a mature Windows programming language. The C language is a language that is very popular with programmers, especially VCI as a target-oriented language, has many basic functions of the Windows environment, such as OLE, ODBC, etc. With ODBC, you can easily connect a variety of databases such as FoxPro, Access, and DBASE, without considering the differences in various database structures. The following is an example of a WIN CGI connection database using a WIN CGI connection database. Users can choose on the screen to query the ISP service provider's Internet service price list. The system environment uses Windows 95, the database uses FoxP RO2.5, and WWW Server uses WebSite. 1. Establishing a database This example The CGI program is connected to the database through the ODBC, so after the database is built, apply 32-bit ODBC drivers to register. 2. Write an HTML program user to select a service type on the screen, press the "Submit" button to query each price column of this service type. Its HTML text is described below:
{title> Wikko Internet Service Charges title> head>Wikco Internet Service Charges h1> P >