Forum Moderators: coopster

Message Too Old, No Replies

Get Referer For Shopping Site

         

Angelis

11:07 am on Feb 22, 2006 (gmt 0)

10+ Year Member



Hi I have a website that has a thank you page after you pay for an item through Paypal.

I need to be able to redirect browsers who dont come from the payment system e.g. by going directly to the page via a search engine.

Problem is, Paypal doesnt send a uniform URL back it has a product ID on the end of it and so it is never the same...

Can someone tell me how to grab the referer on the thank you page and check if it contains paypal.com

Ive been at this for a while and cant get it to work. If the referer isnt paypal.com I need the script to redirect using header(Location....

Thanks in advance.

A

whoisgregg

3:44 pm on Feb 22, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can access the referrer by using $_SERVER['HTTP_REFERER'] [us2.php.net]. :)

Angelis

5:02 pm on Feb 24, 2006 (gmt 0)

10+ Year Member



Yes I know however I need to set the page so that if the referer doesnt come from paypal.com then they are redirected. Problem is the paypal page spits out a ton of variables after the payment has been processed so the referer string is never the same.

I need to be able to check the referal string basically so that it contains the word paypal somewhere so that I can redirect unwanted visitors to that page.

whoisgregg

7:49 pm on Feb 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perhaps stristr [php.net] and some parse_url [php.net] would be sufficient?

Warning, untested code:

$referrer_parsed = parse_url($_SERVER['HTTP_REFERER']);
if (stristr($referrer_parsed['host'], 'paypal')!= FALSE) {
echo 'Referring host contains the string paypal';
}