CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Forms within a script



Aug 24, 2000, 9:32 AM

Post #1 of 2 (406 views)
Forms within a script Can't Post

Hi there,

I have a perl script that prints an HTML form on the fly, this is simple, but I want the form action to call another sub routine in the script, how do I do this, and do I need to save the form results in to a temporary file first?


Dizzie Scripts

User / Moderator

Sep 1, 2000, 5:41 AM

Post #2 of 2 (406 views)
Re: Forms within a script [In reply to] Can't Post


When you print the HTML form from the script,
have it make the value of the submit button different. (ie.. the first time the form prints, let the submit button value be 'Start'. When you print the results and
the new form, have the value of the submit button be 'Step 1', etc.

Now, in your script, put a conditional statement in the beginning like this:

use CGI;
use CGI::Carp 'fatalsToBrowser';
my $q = new CGI;

my %p;

foreach ($q->param){
$p{$_} = $q->param($_);

# ... # do other common processing

if ($p{Submit} eq 'Start'){
# ... do something for the start page
elsif ($p{Submit} eq 'Step 1'){
# ... do something special for step one.
else {
# ... do something else or die if the
# button name is invalid



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives