PDA

View Full Version : newbie help


eagle_1010
11-24-2005, 01:14 AM
Hi

I would like to know how to do the following:

I have a perl script which just displays some text, a submit button and a text box. great!

now what I want to do is process it - so, how can I pass the value of the textbox (after the user hits the submit button) to another perl script? (different pl/cgi file)?

FishMonger
11-24-2005, 01:34 AM
In your current script, the form's action peramature needs to point to the script that will process the form. The processing script should use the CGI module to retrieve the form submission.

#!/usr/bin/perl

use strict;
use warnings;
use CGI qw(:standard);

my $text = param('name_of_text_field');

# do what you will with the info

eagle_1010
11-24-2005, 01:38 AM
ah wow! Thanks for the quick response :)

well i got my first page working... which displays the form in CGI. The POST action I have told it to direct to the other cgi file:


print "<form action=\"./hello2.pl\" method=\"POST\">\n";


so, when the user hits the submit button - what exactly do I need to do to pass it the value of the textbox to the next cgi file? (hello2.pl)? or does that get sent automatically?

I understand, on my 2nd scripting file, I use


my $someVar = param("the_name_of_textbox");


but what about submitting the value of the textbox from the first cgi form?

FishMonger
11-24-2005, 01:54 AM
When the user hits the submit button, the text field value is automaticly sent to the hello2.pl script. If you want to post your complete script(s), I'll see if any corrections need to be made.

To start with, let's clean up the "leaning tower" problem by altering your quotes.
print "<form action='./hello2.pl' method='POST'>\n";
And, since the default method is POST, you don't need to include that part.
print "<form action='./hello2.pl'>\n";

_Aerospace_Eng_
11-24-2005, 03:25 AM
The default is actually GET well at least in IE and FF.