Soooo basically you want a PHP script that will say something like "Hello Googler" if the user came to your site off of a Google search?
In that case, I'll try to have something working for you shortly.
Taken from php.net's $SERVER page:
Quote:
|
Originally Posted by PHP.net
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
|
K done, it searches for a name, so just put anything in there where 'google' is and it'll find it.
PHP Code:
<?php
function is_ref_legal($ref) { return preg_match("/google/i",$ref); }
if (is_ref_legal($_SERVER['HTTP_REFERER'])=="1") { echo 'a'; //Was found } else { echo 'b'; //Was not found } ?>
Keep in mind that if you want to add a slash (/) to the preg_match (example: directory/subdirectory) into (directory\/subdirectory), because a slash will end the preg_match.
Last edited by Physicsguy; 08-07-2010 at 09:53 AM..
|