#!/bin/perl # # PROGRAM: password_field.cgi # # PURPOSE: Demonstrate (1) how to create a password field and # (2) how to determine the value of the field. # # Copyright DevDaily Interactive, Inc., 1998. All Rights Reserved. # #------------------------------# # 1. Create a new CGI object # #------------------------------# use CGI; $query = new CGI; #----------------------------------# # 2. Print the doctype statement # #----------------------------------# print $query->header; #----------------------------------------------------# # 3. Start the HTML doc, and give the page a title # #----------------------------------------------------# print $query->start_html('My password_field.cgi program'); #--------------------------------------------------------------# # 4a. If the program is called without any params, print # # the password_field form. # #--------------------------------------------------------------# if (!$query->param) { print $query->startform; print $query->password_field(-name=>'the_password', -size=>35, -maxlength=>50); # Note: password_field can also take a '-value' parameter, # that can be used as a default value to display. # Using that parameter also, the entry above might look like # this: # #print $query->password_field(-name=>'the_password', # -value=>'default value', # -size=>35, # -maxlength=>50); print $query->br; print $query->submit(-value=>'Submit your password'); print $query->endform; } else { #----------------------------------------------------------# # 4b. If the program is called with parameters, retrieve # # the 'the_password' parameter, save it in a variable # # named $yourPassword, and then print it out. # #----------------------------------------------------------# print $query->h3('The password is:'); $yourPassword = $query->param('the_password'); print "
\n"; print $yourPassword; print "
\n"; } #--------------------------------------------------# # 5. After either case above, end the HTML page. # #--------------------------------------------------# print $query->end_html;