Home » Database Basics » 09 - Database Programming - ODBC and the Web
9

HTML and CGI

Hypertext Markup Language and Common Gateway Interface

The special format of files being exchanged over the web is referred to as Hypertext Markup Language. Static HTML documents often contain hyperlinks that lead to other web pages on the same server or an entirely different folder. While HTML is ubiquitous, it is not very useful when the client wants to send information back to the server - when there is a need to collect data in a form, for example. The HTML FORM and related INPUT elements were added to the HTML specification to allow the user to enter data into HTML pages. Key improvements in server software allowed this information to be transferred to the server as part of an 'HTTP request'. The web server sends this information to other programs that respond according to the information entered by the user. Web pages containing HTML forms use the Common Gateway Interface (CGI) technology to pass information entered by the user to the server.

Figure 9c: HTML requests over the internet
Figure 9c: HTML requests over the internet

The HTML FORM tag usually contains an action attribute that specifies a server side program or script that is called when the form's SUBMIT button is pressed. This action refers to a file like http://www.somewebsite.com/serverscript.asp. A form's METHOD attribute (usually GET or POST) determines how information from the form is transmitted to the server. The information entered by the user is sent to the server as a series of name-value pairs - the names of the different fields, text boxes, checkboxes etc. in the html form and the values that the user entered in them. The name-value pairs are appended to the URL request address itself if the GET method is used. The POST method passes the name value pairs in a special section of request to the server.

For example, if a user entered 'DBMS' in the search field (lets say the name of this field is set to keyword) of a site that uses a GET method for the search form and if this form has the file 'search.asp' in the action attribute, the program is sought on the web server of the site in the following way:

http://www.myserver.com/search.asp?keyword=DBMS