Databases Reference
In-Depth Information
Figure 18-1. The animals form using the CGI pop-up menu
<form method="post" action="http://localhost/cgi-bin/mysql.cgi.animals.popup.pl"
enctype="multipart/form-data">
Animal Name:
<select name="Name" tabindex="1">
<option value="cats">cats</option>
<option value="dogs">dogs</option>
<option value="emus">emus</option>
<option value="fish">fish</option>
</select>
<br />
<input type="submit" tabindex="2" name="submit_button" value="Submit query" />
</form>
Figure 18-1 shows a screenshot of this form.
Using One Script for the Form and for Processing
It's convenient to write a single script to generate both the form and the results web
pages. The script tests whether there is any form data. If there isn't any form data, the
form is displayed; otherwise, the results are shown. In such a script, the value used for
the form action field will be the name of the script itself. For example, the script
query.pl would have:
start_form(-action=>"query.pl", -method=>'POST')
Rather than hardcoding the filename into the program code, we can use the url( )
function to automatically provide the address of the current script:
start_form(-action=>url(), -method=>'POST')
Note that the url( ) function provides the absolute URL of the current script, for
example:
http://localhost/cgi-bin/query.pl
 
Search WWH ::




Custom Search