Forum Moderators: coopster
<?php
header("content-type:text/html");
$mysite = 'example.com';
//
if (isset($_SERVER['HTTP_REFERER'])) {
echo "<p>Someone clicked a link</p>";
if (preg_match("/$mysite/i",$_SERVER['HTTP_REFERER'])) {
echo "<p>Linked from my server</p>";
}
else { echo "<p>Coolio, someone off-site linked to me.</p>"; }
}
else { echo "<p>Direct Request, hey, a visit is a visit.</p>"; }
echo "<p><a href=\"https://www.example.com/referer.php\">Test it</a></p>";
?>
<RANT> (I don't know WHY the environment variable has one "R" in the middle and the proper spelling is with two, REFERRER. Probably the same reason Perl supports "esle" for "else" . . .)
Note: spelling of 'referer' and 'referal' is intentional.