Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referral URL in php

Tags:

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?

<?php 

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

?>

(added this after some answers) I have also tried

print $_SERVER["HTTP_REFERER"];

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 :)

like image 244
user220755 Avatar asked Jan 15 '10 06:01

user220755


1 Answers

Have you tried accessing through the $_SERVER superglobal?

print $_SERVER["HTTP_REFERER"];
like image 64
Sampson Avatar answered Sep 18 '22 09:09

Sampson