Skip to main content
January 24, 2012
Question

PHP help...HTTP_REFERER

  • January 24, 2012
  • 1 reply
  • 523 views

Ok, once again I am completely stumped.

Im sure someone can answer this pretty easily - but for some reason I am having major issues.

Here is the code:

session_start();

include_once "folder/connect_to_mysql.php";

$ref = parse_url($_SERVER['HTTP_REFERER']);

$host = $ref["host"];

if ($host != "www.(my site here).com") {

          echo "Crap! Something broke on the backend...";

          exit();

}

needless to say, it always echos out the "Crap! Something broke on the backend..."

I cannot figure out why though.

Any ideas?

This topic has been closed for replies.

1 reply

Participating Frequently
January 24, 2012

Have you tried to echo the actual value of the referrer ($ref), or of the $host value? That will tell you why it is happening.

A likely cause is that the referer is being blocked. Browsers, firewalls, and proxy servers can all block http referers, which is why it's usually not a good idea to rely upon their values. What are you planning to use the referer value for?