> -----Original Message-----
> From: Hughes, Andrew [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 18, 2002 10:02 AM
> To: [EMAIL PROTECTED]
> Subject: more redirect script problems
> 
> 
> I am still trying to create this redirect script that is 
> called when the
> referring page refreshes after 0 seconds (with a meta tag) to the
> redirect.pl.  I am having a couple of problems.  The first is 
> that when it
> refreshes the scripted does not recognize the page as the 
> referring page.
> Each time I test it, my "else" statement is executed with the message,
> "CGI=HASH(0x80fbc2c)->referer is not a valid. Please check 
> the address and
> try again."  When I hard code a link to the script, and click 
> on it, I get
> an error that reads, "Undefined subroutine &main::meta called 
> at redirect.pl
> line 14."  Does anyone have an idea on how to make this 
> script work or to go
> about it differently?  Any/All suggestions are appreciated.
> 
> Thanks,
> Andrew
> _________________________________________
> 
> #!/usr/bin/perl -wT
> use CGI; 
> use CGI::Carp 'fatalsToBrowser';
> use strict;
> 
> my $q = new CGI;
> 
> my $referer = $q->referer;
> #my $onesite_atlhmbnk =
> $q->param('http://www.mysite.com/atlhmbnk/index.html');
> #my $onesite_atlcas = 
> $q->param('http://www.mysite.com/atlcas/index.html');
> #my $onesite_brook = 
> $q->param('http://www.mysite.com/brook/index.html');
> 
> 
> if ($referer eq "http://www.mysite.com/atlhmbnk/index.html";) {
> print $q->header("text/html"),
>       $q->start_html(-head=>meta({-http_equiv=>'Refresh',
>                    -content=>'0;
> URL=http://www.mysite.com/atlcas/site.html'})),
>       $q->p("This is atlcas"),
>       $q->end_html;
> }
> 
> 
> elsif ($referer eq "http://www.mysite.com/atlcas/index.html";) {
> print $q->header("text/html"),
>       $q->start_html(-head=>meta({-http_equiv=>'Refresh',
>                    -content=>'0;
> URL=http://www.mysite.com/atlhmbnk/site.html'})),
>       $q->p("This is atlhmbnk"),
>       $q->end_html;
> }
> 
> 
> elsif ($referer eq "http://www.mysite.com/brook/index.html";) {
> print $q->header("text/html"),
>       $q->start_html(-head=>meta({-http_equiv=>'Refresh',
>                    -content=>'0;
> URL=http://www.mysite.com/brook/site.html'})),
>       $q->p("This is brook"),
>       $q->end_html;
> }
> 
> else {
> print $q->header("text/html"),
>       $q->start_html,
>       $q->p("$q->referer is not a valid.  Please check the 
> address and try
> again."),
>       $q->end_html;
> }

A couple of comments/observations:

1. The CGI module has a redirect() method for handling redirects. Have you
looked at that?

2. In my experience, the browser does not update the Referer: header when
doing a redirect. The safest technique is to probably pass the referer
along with the redirect uri, rather than depending on any particular client
behavior.

3. You can't expand method calls inside double quotes like 

   $q->p("$q->referer is not a valid").

That's why you're getting

   CGI=HASH(0x80fbc2c)->referer is not a valid

Try just:

   $q->p($q->referer . " is not a valid").

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to