in reply to Redirecting Problem

Straight from the CGI docs:

print $query->redirect('http://somewhere.else/in/movie/land');

_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche

Replies are listed 'Best First'.
Re: Re: Redirecting Problem
by Rex(Wrecks) (Curate) on Aug 08, 2002 at 17:05 UTC
    Just as an FYI, I had the same issue as VFT when I was learning CGI. The print $query->redirect('http://somewhere') ; must not appear AFTER a print $query->header() ; as it IS your header.

    "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!
      Thanks, I'm so glad I am not the only one that's been through this! And thanks for letting me know it IS my header, which still sorta confuses me...does that mean I will no longer need print $query->header; , I just replace it with the redirect script you have?

      I installed it by deleting my other header print, but I ran into another problem. I am doing:
      my $url; $url = 'www.site.com';
      But when I try $query->redirect('$url') ; it's trying to show me you can't use a scalar here. Is this true?

      Thanks so much!

        Try using double quotes " instead of ' or don't use quotes at all. I.e.,
        print $query->redirect($url); or print $query->redirect("$url"); # unnecessary double quotes

        Single quotes don't interpolate.
        Hi VFT,

        Single quotes ( '' ) don't allow variable interpolation where as double quotes ( "" ) do. Here is an example:
        #!c:\perl\perl.exe -wT use strict; use CGI; use CGI::Carp qw( fatalsToBrowser ); my $q = new CGI; my $url = "http://www.google.com"; print $q->redirect("$url"); print $q->header();

        Hope this helps,

        -Katie.
        A reply falls below the community's threshold of quality. You may see it by logging in.
        a $query->redirect($url) should do the trick.

        Do you mean  $query->redirect($url) maybe?

      A reply falls below the community's threshold of quality. You may see it by logging in.