CGI Forms   «Prev  Next»

Lesson 8

Perl CGI Web Forms Conclusion

This module discussed why Web forms are a powerful tool for gathering data from users on a Web site.
When used properly, forms can allow users to interact with your Web site in a more participatory manner than static Web pages allow.
Web forms are capable of presenting different types of widgets for different purposes, and of presenting gathered information to your CGI program.
In this module you have learned about the following:
  1. The different types of widgets available
  2. The appropriate use for each of them
  3. The POST and GET methods of submitting forms data to CGI programs
  4. The circumstances under which you use these different methods
In the next module you will learn more about how Perl interfaces with CGI and the Web browser. Specifically, you will learn techniques for maintaining the state of the user via hidden fields and cookies. Using hidden fields with the state-machine model, it is possible.

Perl Complete Reference
Some of the input fields you can use in your form include:

TEXT

A text input field
<INPUT TYPE="TEXT" NAME="email_address" VALUE="bob@hotmail.com">
This can be created by either:
print textfield({-name=>"email_address",
-value=>"bob\@hotmail.com"});
# or
print input({-type => "text",
-name => "email_address",
-value => "bob\@hotmail.com"});

HIDDEN

Hidden fields allow us to pass data around without having to display it to the user. Using hidden does not mean that the user cannot see the data, because it is there in the source, but it means that the user doesn�t have to worry about it. Hidden fields should always have a value defined.

<INPUT TYPE="HIDDEN" NAME="stage" VALUE="3">

This can be created by either:
print hidden({-name=>"stage",
-value=>"3"});
# or
print input({-type => "hidden",
-name => "stage",
-value=> 3 });