Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

redirection in perl

by anbutechie (Sexton)
on Apr 25, 2009 at 03:39 UTC ( [id://759951]=perlquestion: print w/replies, xml ) Need Help??

anbutechie has asked for the wisdom of the Perl Monks concerning the following question:

hi,
I m using CGI module. I have created two forms. one for login page another for home page. On correct username and password, it should be redirect to home page. I used
redirect(-url=>$homepageurl);
Actually it fails to redirect instead it prints "Status:302 Location:$homepageurl. Kindly let me know how to use redirect method.

Regards,
Anbarasu

Replies are listed 'Best First'.
Re: redirection in perl
by Your Mother (Archbishop) on Apr 25, 2009 at 03:58 UTC

    Sounds like you're printing the headers twice. The headers you describe are correct for a redirect (if $homepageurl is a real URL). If they're showing up on the web page it's because other headers were printed (or automatically sent/output by the server in some edge configuration cases) first.

    redirect outputs headers so if you're also doing print header()... you need to put it into a logic check (like if/else) so you only print one set of headers.

Re: redirection in perl
by apl (Monsignor) on Apr 25, 2009 at 13:47 UTC
    Among other things, you should print out the value of $homepageurl when reporting the error, so you can determine if your URL is correct/valid...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://759951]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-03-28 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found