user220755 user220755 - 1 year ago 352
PHP Question

Referral URL in php

So I am trying to get the page where a visitor came from. I inserted this code into a php file and I am trying to see the page's URL but it is not working, any suggestions?


$ref = getenv("HTTP_REFERER");
echo $ref;


(added this after some answers)
I have also tried


and that doesn't work either

it worked after i updated the website many times, not sure why was there a problem in the first place, thanks anyway :)

Answer Source

Have you tried accessing through the $_SERVER superglobal?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download