Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: CGI::Application redirecting from one handler to another.

by Chmrr (Vicar)
on Jan 02, 2004 at 18:16 UTC ( #318387=note: print w/ replies, xml ) Need Help??


in reply to CGI::Application redirecting from one handler to another.

Having just solved a very similar problem, I would suggest the following pseudocode. What it boils down to is using the query object to pass parameters to the other runmodes.

sub join { # This is the 'join' runmode my $self = shift; my $q = $self->query; # It submits to the verify runmode if ($self->query->param('error')) { # We just tried to submit, but had error(s); print them } # Print the rest of the form, etc } sub verify { # 'verify' runmode my $self = shift; my $q = $self->query; # Do error checking unless (@errors) { # This is how we 'redirect' without redirecting. $q->param('username',$username); $q->param('password',$password); return $self->create; } else { $q->param(-name => 'error', -value => \@errors); return $self->join; } } sub create { # 'create' runmode my $self = shift; my $q = $self->query; # Create the account return $self->viewprofile; } sub viewprofile { # 'viewprofile' runmode # ..uses $q->param('username') which is either supplised by the user +, or # by the code in 'verify', which was passed to 'create' and then on # to us. }


Comment on Re: CGI::Application redirecting from one handler to another.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-07-03 13:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls