faqts : Computers : Programming : Languages : PHP : Common Problems : Visitor Information

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 6 people (83%) answered Yes
Recently 5 of 6 people (83%) answered Yes

Entry

How can I detect in PHP whether a request originated via the browser's address or via a link ?

Jun 24th, 2004 12:04
Philip Olson, David Crossley,


Although not perfect you can check for the HTTP predefined variable 
named HTTP_REFERER so for example:
  if (isset($_SERVER['HTTP_REFERER'])) {
    echo "Hi, you came from the link: " . $_SERVER['HTTP_REFERER'];
  } else {
    echo "Not sure where you came from!";
  }
If you create the links yourself then you could do various things like 
pass a variable via GET (in the URL) and check that, or, use a 
SESSION, but most likely that's not your question.