The data from the form and the query string
is stored in such a way that you need to parse it.
Parsing means extracting items from a continuous
string of items.
Fortunately you do not need to write a Perl program
to parse out the data from a form.
There are many parsing programs already written that you use.
A popular parsing program is CGI.PM available on the Web.
Most parsing program require that you provide an associative
array name of your choosing. Then the parsing program uses
the HTML form element names to create your associative array's
keys.
For example consider this HTML for a form
<form action="joinus.pl" method=post>
First name:
<input type=text name=first size=20>
<br>Last name:
<input type=text name=last size=20>
<hr>
<input type=submit value="Join">
<input type=reset>
</form>
Suppose that you use a parsing program to create an
associative array called FormData.
The parsing program will create keys for the
FormData array so that you can access the data from the
the form's elements as follows:
$FormData{'first'}
$FormData{'last'}
An example of using the data is as follows
print "Welcome $FormData{'first'} $FormData{'last'} ";
print "to our Web site building club!";
No keys are created in the FormData array for the submit and reset buttons
This is because the name attribute was not used in the HTML
for these buttons.
|
|