[LA.pm] CGI problem
David Heayn
david at cloudgraphics.com
Sat Jun 25 18:52:35 PDT 2005
I'm having a frustrating time coding up a CGI mechanism.
Basically, below prints out an HTML form (that was generated in a web
editor, not by hand), unless the Param() function is filled. The
printing of a blank form works fine, however, when I send data back
to the script I get an "Internal Server Error."
I have Lincoln Stein's cgi.pm book but he doesn't go into detail
about how to handle form: drop down menu options.
What am I doing wrong?
#!/usr/local/bin/perl -w
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
warningsToBrowser(1);
use lib qw( ..);
my $cgiLoc = "http://www.cloudgraphics.com/cgi-bin/refer.cgi";
if (param('action'))
{
print "<HTML>\n";
print "<BODY>\n";
my $year = param('year');
my $month = param('mo');
my $day = param('day');
print "$month/$day/$year<BR>\n";
print "</BODY></HTML>\n";
}
else
{
print <<HTML_BLOCK;
<html>
[snip]
<form method="get" action="$cgiLoc"
enctype="application/x-www-form-urlencoded">
<div align="center">
<select
name="mo" size="1">
<option value="01">Jan</option>
<option value="02">Feb</option>
<option value="03">Mar</option>
<option value="04">Apr</option>
<option value="05">May</option>
<option value="06">Jun</option>
<option value="07">Jul</option>
<option value="08">Aug</option>
<option value="09">Sep</option>
<option value="10">Oct</option>
<option value="11">Nov</option>
<option value="12">Dec</option>
</select>/<select name="day" size="1">
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
</select>/<select name="year" size="1">
<option value="07">2007</option>
<option value="06">2006</option>
<option value="05">2005</option>
<option value="04">2004</option>
<option value="03">2003</option>
<option value="02">2002</option>
<option value="01">2001</option>
<option value="00">2000</option>
<option value="99">1999</option>
<option value="98">1998</option>
</select></div>
<div align="right">
<p><input type="submit" tabindex="2" name="action" value="Process"></p>
</div>
</form>
</body>
</html>
HTML_BLOCK
}
David Heayn * http://www.cloudgraphics.com * 213/925.3283
More information about the Losangeles-pm
mailing list