![]() |
|
| • All Online Courses • New Courses • QuickTips • Word Definitions • Submit a Tutorial • Links • |
|
Beginning CGI Programming with Perl HTML, HTTP, and Your CGI ProgramHTML, HTTP, and your CGI program have to work closely together to make your online Internet application work. The HTML code defines the way the user sees your program interface, and it is responsible for collecting user input. This frequently is referred to as the Human Computer Interface code; it is the window through which your program and the user interact. HTTP is the transport mechanism for sending data between your CGI program and the user. This is the behind-the-scenes director that translates and sends information between your Web client and your CGI program. Your CGI program is responsible for understanding both the HTTP directions and the user requests. The CGI program takes the requests from the user and sends back valid and useful responses to the Web client who is clicking away on your HTML Web page. The Role of HTMLHTML is designed primarily for formatting text. It is basically a typesetting language that specifies the shape of the text, the color, where to put it, and how large to make it. It's not much different from most other typesetting languages, except that it doesn't have as many typesetting options as most simple What You See Is What You Get (WYSIWYG) editors, such as Microsoft Word. So how does it get involved with your CGI program? The primary method is through the HTML Form tags. Your CGI program does not have to be called through an HTML form, however; it can be invoked through a simple hypertext link using the anchor (<a>) tag-something like this: <a href="A CGI program"> Some text </a> The CGI program in this hypertext reference or link is called (or activated) in a manner similar to that used when being called from an HTML form. You even can use a hypertext link to pass extra data to your CGI program. All you have to do is add more information after the CGI program name. This information usually is referred to as extra path information, but it can be any type of data that might help identify to your CGI program what it needs to do. The extra path information is provided to your CGI program in a variable called PATH_INFO, and it is any data after the CGI program name and before the first question mark (?) in the href string. If you include a question mark (?) after the CGI program name and then include more data after the question mark, the data goes in a variable called the QUERY_STRING. Both PATH_INFO and QUERY_STRING are covered in Tutorial 6. So to put this all into an example, suppose that you create a link to your CGI program that looks like this: <a href=www.practical-inet.com/cgibook/chap1/program.cgi/ extra-path-info?test=test-number-1> A CGI Program </a> Then when you select the link A CGI program, the CGI program named program.cgi is activated. The environment variable PATH_INFO is set to extra-path-info and the QUERY_STRING environment variable is set to test=test-number-1. Usually, this is not considered a good way to send data to your CGI program. First, it's harder for the programmer to modify data that is hard-coded in an HTML file because it cannot be done on-the-fly. Second, the data is easier to modify for the Web page visitor who is a hacker. Your Web page visitor can download the Web page onto his own computer and then modify the data your program is expecting. Then he can use the modified file to call your CGI program. Neither of these scenarios seems very pleasant. Many other people felt the same way, so this is where the HTML form comes in. Don't completely ignore this method of sending data to your program. There are valid reasons for using the extra-path-info variables. The imagemap program, for example, uses extra-path-info as an input parameter that describes the location of mapfiles. Imagemaps are covered in Tutorial 9 "Using Imagemaps on Your Web Page." The HTML form is responsible for sending dynamic data to your CGI program. The basics outlined here are still the same. Data is passed to the server for use by your CGI program, but the way you build your HTML form defines how that data is sent, and your browser does most of the data formatting for you. The most important feature of the HTML form is the capability of the data to change based on user input. This is what makes the HTML Form tag so powerful. Your Web page client can send you letters, fill out registration forms, use clickable buttons and pull-down menus to select merchandise, or fill out a survey. With a clear understanding of the HTML Form tag, you can build highly interactive Web pages. Because this topic is so important, it is covered in Tutorials 4 and 5, and the hidden field of the HTML form is explained in Tutorial 7 "Building an Online Catalog." So, to sum up, HTML and, in particular, the HTML Form tag, are responsible for gathering data and sending it to your CGI program.
by Frontsource.com.pk Find more free Internet tutorials from Learnthat.com. More Information:
Help us by rating this tutorial: [---] [--] [+] [++] [+++] [---] lowest; [+++] highest
|
|
||||||
![]() |
Learn: Free
Tutorials - Links
to Free Tutorials
Understand: Free Technical Definitions
- ExplainThat Whitepapers
Use: Certification Section -
Discussion Forum
Visit Our Network Sites:
About Us : Contact Us : Advertise : Privacy Information