Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Multi page form

by Purdy (Hermit)
on Sep 28, 2005 at 14:16 UTC ( #495755=note: print w/replies, xml ) Need Help??

in reply to Multi page form

Sounds like you're evolving - I highly recommend proceeding the next step & evolving to a MVC CGI framework, like CGI::Application - it would work something like this:
#!/usr/bin/perl -wT # this would be your .cgi file... let's say name.cgi use strict; use CGI::Carp qw( fatalsToBrowser ); $|++; use MyApp; my $webapp = MyApp->new(); $webapp->run();
Then a complementing cgiapp module:
package MyApp; use strict; use base 'CGI::Application'; sub setup { my $self = shift; my $self->run_modes( [ qw( start add addnew ) ] ); } sub start { my $self = shift; my $query = $self->query; my $output = $query->start_html( -title => 'Simple Script' ); $output .= '<a href="name.cgi?rm=add">Start</a>' . $query->end_html; return $output; } sub add { my $self = shift; my $query = $self->query; my $output = $query->start_html(-title=>$title.' Enter your name'); $output .= $query->start_form . $query->hidden( 'rm', 'addnew' ) . $query->textfield('name','Enter Your name',20) . $query->submit('submit') . $query->reset . $query->end_form . $query->end_html; return $output; } sub addnew { my $self = shift; my $query = $self->query; my $text = 'Error , You should write your name'; if ( $query->param( 'name' ) ) { $text = "Welcome $name"; } my $output = $query->p( $text ); return $output; } 1;
HTH & Good Luck! - Jason

Update: Feel free to drop in on the #cgiapp channel on
Update2: bugfix ... that's not really the best code -- just something I whipped up as a prototype

Replies are listed 'Best First'.
Re^2: Multi page form
by Anonymous Monk on Sep 28, 2005 at 15:09 UTC

    Thanks for your reply

    i have tryed your example and still facing the same problem it doesn't switch to the 3rd step.

    stuck in the 2nd page

      Did you get my latest code?

      In regards to your original code, my guess is that action parameter for your form is invalid. I've never done it that way - I've instead used hidden fields. So in your $action eq 'add' branch, set the action of the form to the name of your cgi script. Then add a hidden field:

      # ... }elsif($action eq "add"){ print start_html(-title=>$title.' Enter your name'); print start_form(-action=>"myscript.cgi"), # is that the name? hidden( 'action', 'add' ), textfield('name','Enter Your name',20), submit('submit'),reset, end_form,end_html; # ...

      HTH & Have Fun!

      - Jason

      PS: Drop by the #cgiapp channel & we can help you further...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://495755]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2019-12-16 11:18 GMT
Find Nodes?
    Voting Booth?

    No recent polls found