Hi all,
I'm fairly new here, so would appreciate any help offered
I've written some Perl CGI scripts to retrieve form data and process it using the cgi-lib.pl library. I'm still learning as I go, but have found a lot of useful info on the web and have put together a few working scripts, so thought I'd figured it all out.
However... I've now tried pulling out information from a radio button selection and just can't get the value being passed through. I've checked the HTML source is correct (see below) and even simplified the Perl script to be completely trivial, but with no luck.
I was wondering if this was a common problem, or if I'm just being dense... [Edit: No wait - I'm being dense as I just tried pulling in text info, which I can't do either... Just not sure where I'm being dense.]
Here's the relevant section of HTML source (automatically generated from another script):
<table>
<tr><td><input name="result" value="1" type=radio></td><td>Tony</td><td>Test 1</td></tr>
<tr><td><input name="result" value="2" type=radio></td><td>Mikey</td><td>Test 2</td></tr>
<tr><td><input name="result" value="3" type=radio></td><td>Stoney</td><td>Test 3</td></tr>
</table>
<form action="../cgi-bin/caption-vote-cgi.pl" method="POST">
<input type="submit" value="Vote"><input type="reset">
My Perl script...
#!/usr/bin/perl -w
require "cgi-lib.pl";
# ============== #
# Configuration stuff
# ============== #
$textfile = './data/caption.tmp';
$debug = './data/caption.log';
$html = '../html/caption-prev.html';
$cgi_script = '../cgi-bin/caption-cgi.pl';
$cap_result = 0;
$cap_winner = ' ';
# ============== #
# MAIN Function section
# ============== #
# Flush straight away - which apparently is good?
$|=1;
# Open debug output file
open(DEBUG, ">$debug") or &dienice("Can't access $debug!\n"); #<-- This is so I could get some debug output when the file was running
print DEBUG "Debug log opened\n";
&ReadParse(*input);
$cap_result = $input{'result'};
print DEBUG "Form Value for result = [$cap_result]";
showEnd();
close(DEBUG);
# ============== #
# SUB-ROUTINES
# ============== #
# This subroutine handles the file open error
sub dienice {
($errmsg) = @_;
print "<h2>Error</h2>\n";
print "$errmsg<p>\n";
print "</body></html>\n";
exit;
}
# This subroutine shows the final thank you message
sub showEnd {
print "Content-type: text/html\n\n";
print <<EndHTML;
<HTML>
<HEAD>
<TITLE>Complete</TITLE>
</HEAD>
<BODY>
<H1>Update Complete</H1>
Result = [$cap_result]
<P>Previous results updated</P>
<P>View generated page <A HREF="$site_url">$site_name</A>.</P>
</BODY>
</HTML>
EndHTML
}
The web page just shows "Result = []", as does the debug log file. Any thoughts?