LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-19-2004, 09:38 AM   #1
stoney79
LQ Newbie
 
Registered: Jul 2003
Posts: 12

Rep: Reputation: 0
CGI Posting Probs...


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?

Last edited by stoney79; 04-19-2004 at 10:07 AM.
 
Old 04-19-2004, 10:16 AM   #2
stoney79
LQ Newbie
 
Registered: Jul 2003
Posts: 12

Original Poster
Rep: Reputation: 0
It was the ordering of the <form> and <input> tags, right?

I'll get me coat...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CGI to work out side of cgi-bin? crashedspine Linux - Newbie 13 09-02-2004 08:49 PM
Probs running .jar file via CGI script under Apache blimbo Programming 1 07-22-2004 10:29 AM
Posting to CGI Forms goldcougar Linux - Newbie 1 07-02-2004 10:13 AM
POSTing to Cgi binaries nodger Programming 1 01-23-2004 09:15 AM
http://www.burstnet.com/cgi-bin/ads/ad7954a.cgi/3980/RETURN-CODE rverlander LQ Suggestions & Feedback 1 06-07-2002 07:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration