![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Perl CGl Programming: No experience required.
Submitting the Formform1.html uses very few of HTMLs tricks, just a few text input types and the submit and reset buttons. Your purpose here is not to see how great-looking forms are put together, but to learn what happens when you or one of your visitors clicks that submit button. There are two methods that can be used to send out the forms datathe information that has been entered in its fieldsand these are specified in the METHOD parameter to the HTML FORM command. You have used GET in this example; the other choice is POST. The difference between them is in how they send the data. As you will see, your choice in methods will be determined by the amount of data in the form; very generally, GET is used for small amounts and "POST" for large amounts or when you want to hide the information from the user. You used GET in the example for two reasons: First, its short. Second, without even loading it on a Web site, you can get a visual idea of how the data are sent when you submit the form. Create something to fool the browser. On Windows NT or Windows 95, if Perl is in your path (and it should be!), you can create a little file called perl.bat that has nothing in it but the word perl. A shell script on UNIX would accomplish the same thing. Save it in the same directory in which you put form1.html, then crank up your Web browser of choice and open the file.
Fill out the form with anything that fits. Figure 5.4 illustrates some suggested bogus data.
Now, submit the form by clicking the Send Information button. Figure 5.5 illustrates what appears in Netscape Navigators Location field when you ship this form. The CGI program you specified in the forms ACTION field doesnt do anything, of course, but you can see what would be shipped to it.
This query string is set up by the browser as a URL. You dont have to worry about how its done; any browser will do it automatically. However, you do have to interpret it in your CGI program, so youd better know how its put together. URLs and CGIYou have seen how an HTML form is built and the functions it uses to send information to the Web server. The form the information takes is important, because your Perl program has to be able to interpret it. URLs, or Uniform Resource Locators, were developed as a way to specify resources on the Internet with a single line of printable ASCII text. Notice the emphasis on printablethis will become important to you as you learn to decode the special characters sent in a URL. In its simplest and most familiar form, a URL simply gives the domain name of a Web site, for example, www.rcich.com. URLs arent limited to the World Wide Web. All of the major Internet protocols, such as FTP, Gopher, WAIS, and HTTP, can read and understand a URL. They are set up in a very specific way, containing:
The URL that was constructed by your browser in submitting form1.html is set up in this fashion, with file// as the protocol, and the domain name, port, and resource location all addressed in the path to perl.bat. Figure 5.6 illustrates a full URL pointing over the Internet to the same location.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |