Hello again!
Three posts in this forum now, as I am trying to understand how CGI is running and the interaction of the input and output with the server/browser. Very confused with them, especially with the param() function that I was trying to figure out how the parameters of it were passed in between. Say, with the following script, I swallowed it down with little digestion, and it is working. But I do not know how to modify it for my own purpose.
I seem understanding the general idea of the cooperation among CGI, Apache2 and the Browser, but I am not sure, especially, the CGI functions in detail. In this example, I was expecting "key - value" pairs from param() function as
name Linux
address1 123 streat
address2 Room 123
city New York
State NJ
zip 1X23Y4
country USA
button Enter
but actually nothing was printed. Can anyone explain it for me how these parameters are passed, please? Thanks a lot!
#!/usr/bin/perl -wT
#textform.pl
use strict;
use CGI;
my $q = CGI->new;
# Starters.
print $q->header, $q->start_html('Address info');
# Create a form with text entry fields.
print $q->start_form,
$q->h1('Please enter your address below.'),$q->p,
'Name:',$q->textfield(-name => 'name'),$q->br,
'Address:',$q->textfield(-name => 'address1'),$q->br,
'Address:',$q->textfield(-name => 'address2'),$q->br,
'City:',$q->textfield(-name => 'city'),
'State/Province:',$q->textfield(-name => 'state'),
'Zip/Postal code:',$q->textfield(-name => 'zip'),$q->br,
'Country:',$q->textfield(-name => 'country'),$q->p,
$q->submit('button','Enter'),
$q->end_form;
print "The parameters of the CGI object (\$q) are: ", "\n";
foreach my $member ($q->param()) { #Line 24
print "$member\t"; #Line 25
} #Line 26
print "\n";
# End the document.
print $q->end_html;