PHP

Super Globals

NameValue
HTTP_REFERER If the user clicked a link to get the current page, this will contain the URL of the previous page they were at, or it will be empty if the user entered the URL directly.
HTTP_USER_AGENTThe name reported by the visitor's browser
PATH_INFOAny data passed in the URL after the script name
PHP_SELFThe name of the current script
REQUEST_METHODEither GET or POST
QUERY_STRINGIncludes everything after the question mark in a GET request
<?php
   if (isset($_SERVER['HTTP_REFERER'])) {
      print "The page you were on previously was {$_SERVER['HTTP_REFERER']}<br />";
   } else {
      print "You didn't click any links to get here<br />";
   }
?>

<a href="refer.php">Click me!</a>

José M. Vidal .

5 of 33