#!/usr/local/bin/perl # # textfield.cgi - demonstrate a simple textfield form using CGI.pm # # 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 textfield.cgi program'); #--------------------------------------------------------------# # 4a. If the program is called without any params, print # # the textfield form. Start the form, create the textfield, # # create the submit button, and end the form. # #--------------------------------------------------------------# if (!$query->param) { print $query->startform; print $query->textfield(-name=>'TEXT_FIELD', -default=>'[Enter your text here]', -size=>35, -maxlength=>50); print $query->br; print $query->submit(-value=>'Submit your text'); print $query->endform; } else { #----------------------------------------------------------# # 4b. If the program is called with parameters, retrieve # # the 'TEXT_AREA' data into a variable named $yourText, # # then print that information after an

tag. # #----------------------------------------------------------# print $query->h3('Here\'s what I think you entered:'); $yourText = $query->param('TEXT_FIELD'); print "
\n"; print $yourText; print "
\n"; } #-------------------------# # 5. End the HTML page. # #-------------------------# print $query->end_html;