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

I am having this problem with my BigNoseBird refer a friend script... It sends the email but the script cannot call up the referring page in the script. I at least would like a Thank You Statement or something. Anyway, Here is the link... http://www.PhoneChristian.com and just click on "Refer a Friend" I know that this...
print "Location: $JUMP_TO\n\n";
is the part of BigNoseBird's script that calls the referring page up and I think it is crashing because it trying to find the referrer as the cgi script? Anyway all I would like to is at least make this print statement take people to the homepage if nothing else. What do I need to type in?

Replies are listed 'Best First'.
Re: Returning to A Referring Page
by screamingeagle (Curate) on Jan 20, 2002 at 12:40 UTC
    If you need to retrieve the referring page name, use the environment variable $ENV{'HTTP_REFERER'}.You could try this out :
    $jump_to = $ENV{'HTTP_REFERER'}; print "Location: $jump_to\n\n";
      You will also need to incorporate a default value as you cannot always be sure that the HTTP_REFERER environment variable will be set. eg.

      $jump_to = $ENV{'HTTP_REFERER'} || 'http://www.yourwebpage.com'; print "Location: $jump_to\n\n";

       

      perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'

        Just to make it complete though:
        $jump_to = $ENV{'HTTP_REFERER'} || 'http://www.yourwebpage.com'; print "Status: 302 Moved\n"; # thats the spec print "Location: $jump_to\n\n";
        Some Browsers would ignore the redirection attempt without the correct status. But if you use CGI.pm it will do it for you :-)

        Have a nice day
        All decision is left to your taste