in reply to Re: Redirecting Problem
in thread Redirecting Problem

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!

Replies are listed 'Best First'.
Re: Re: Re: Redirecting Problem
by venimfrogtongue (Novice) on Aug 08, 2002 at 17:13 UTC
    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!

      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.
      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.
        Nope :( I tried single quotes, double quotes, and no quotes. All result in no page loading, sever email spamming, etc. urgh
      a $query->redirect($url) should do the trick.
        in theory it should work, but it won't...

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

        I actually tried it without quotes and it didn't make any difference..
    A reply falls below the community's threshold of quality. You may see it by logging in.