Gossamer Forum
Home : General : Perl Programming :

Any ideas?

Quote Reply
Any ideas?
Hi. I am working on a script that allows you to choose what page is shown if you have a different referer. What i want them to be able to do though is have 2 different site options. I have tried to write this script myself but it wouldn't work! I don't want them to only be redirected to the correctpage is the are reffered from , for example, www.site.com; i want them to be redirected if they are sent from www.site.com/index.html, www.site.com/page.html etc; basically any page on their site without having to manually code it themselves. Does anyone have any ideas?

The code i did use was;

$site = "http://www.site.com";
$referer = "$ENV{HTTP_REFERER}";
if ($referer = $oksite) { &ok } else { &bad }

I have tried many other ways (such as putting an =~ instead of just an = sign, but that didn't work!)

Any ideas would be much appreciated


Yours

A.J.Newby
webmaster@ace-installer.com


Quote Reply
Re: Any ideas? In reply to
= won't work as you're assigning not comparing.

If numbers, use == if words, use eq


Plus your url is in $site, and you're comparing with the variable $oksite.

--mark

Installation support is provided via ICQ at UIN# 53788453. I will only respond on that number.
Quote Reply
Re: Any ideas? In reply to
I tried using;

$site = "http://www.site.com";
$referer = "$ENV{HTTP_REFERER}";
if ($referer eq~ $site) { &ok } else { &bad }

but that didn't work!

Any ideas?

A.J.Newby

Note: I didn't get an error, it just showed &ok sub routine even though the referer was incorrect!



Quote Reply
Re: Any ideas? In reply to
remove the ~

There's no such thing as eq~

--mark

Installation support is provided via ICQ at UIN# 53788453. I will only respond on that number.
Quote Reply
Re: Any ideas? In reply to
Yes...the code needs to look like:

$site = "http://www.site.com";
$referer = "$ENV{HTTP_REFERER}";
if ($referer eq $site) {
&ok
} else {
&bad
}


Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Any ideas? In reply to
umm... not really the code should look like..

$site = "http://www.site.com";
$referer = "$ENV{HTTP_REFERER}";
if ($referer =~ /^$site/) { &ok } else { &bad }

this will match a referer to see if the start of the string contains $site... so it makes sure the referer came anywhere from $site.. ie: http://www.site.com/some/random/directory/index.html would work.. but http://www.notsite.com/anything/ wouldn't work..

Jerry Su
widgetz sucks
Quote Reply
Re: Any ideas? In reply to
That didn't work either! Any more ideas?