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...