okay, here is the perl script I am using:
#!perl-w
unless ($ENV{REQUEST_METHOD} eq "GET") {
print "Content-Type: text/plain
";
print "Method $ENV{REQUEST_METHOD} is unsupported.";
print "Please wait until the next chapter";
}
else {
#get the form data
@name_value_pairs = split(/&/,$ENV{QUERY_STRING});
foreach $pair (@name_value_pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-f0-9][a-f0-9])/chr(hex($1))/ieg;
$form_data{$name}=$value;
}
print "Content-Type: text/html
";
print '<html>',
'<head>',
'<title> Echo form Variables </title>',
'</head>',
'<body>';
print '----- UNPROCESSED FORM DATA -----<p>';
print "$ENV{QUERY_STRING}<p>";
print '----- CLEANED UP FORM DATA -----<p>',
'<table>',
'<tr><th>Name</th>',
'<th>Value</th></tr>';
#print a table row for each form element
foreach $var (keys(%form_data)) {
print "<tr><td> $var </td>";
print "<td> $form_data{$var} </td></tr>";
}
# complete html tags
print '</table></body></html>';
}
and here is the form:
<html><head><title>Form Test</title>
<style type="text/css">
body,td,th {font-family: verdana, arial, sans-sarif; font-size: 10px}
</style>
</head>
<body>
<table border="2" cellpadding="15">
<tr>
<td>
<form method="GET" action="http://localhost/cgi-bin/formData2.cgi">
My name is: <input type="text" name="username" size="20" maximum="20" /><br>
My secret word is: <input type="password" name="secret_word" /><br>
I am: <br>
<input type="radio" name="class" value="Ug">Undergrad<br>
<input type="radio" name="class" value="Gr">Grad<br>
<input type="radio" name="class" value="Al">Alumni<br>
<input type="radio" name="class" value="Other">Just hanging around</br>
I like: <br>
<input type="checkbox" name="Like" value="Web">Making my own Web Pages</br>
<input type="checkbox" name="Like" value="Money">Making Money</br>
<input type="checkbox" name="Like" value="Trouble">Making Trouble</br>
My Advisor is: <br>
<select name="Advisor">
<option>Chang</option>
<option>Gowen</option>
<option>Lightfoot</option>
<optoin>My Mother</option>
</select>
<input type="Submit" value="Do It!" />
<input type=Reset" value="Clear It!" /><p>
<input type="hidden" name="TheRealSecretWord" value="Perl" />
</form>
</td>
</tr>
</table>
</body>
</html>
I am testing this locally, but I keep getting the error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, you@your.address and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Apache/1.3.26 Server at localhost Port 80
but, other scripts work fine, so there must be a problem with my cgi file, but I can’t figure out where.