Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
Quote:
Originally Posted by Marik
If you do decide to use strpos instead of regular expressions here's how:
PHP Code:
<?php
if (strpos($_SERVER['HTTP_REFERER'], "google")) { echo "Google Referer"; } else { echo "No Referer"; }
?>
|
Actually, that's not quite how I'd do it. Although it will work, it would also match websites such as ihategoogle.com, or googlerules.com or googlesucks.com or anything that has the "google" substring in it, even just a link from a site with a directory called or containing google.
but:
PHP Code:
if (strpos($_SERVER['HTTP_REFERER'], "//www.google.") || strpos($_SERVER['HTTP_REFERER'], "//google.")) { echo "Google Referer"; } else { echo "No Referer"; }
will be rock solid.
__________________
I build web things. I work for the startup Please login or register to view this content. Registration is FREE
.
Last edited by wayfarer07; 04-25-2010 at 02:54 PM..
|