PHP Script Help, PLEASE

bert6911

Registered Member
Joined
Apr 23, 2007
Messages
82
Reaction score
37
Ok, I know the answer to this is going to be simple, BUT I have never had to use this type of check before and I don't know the keys/values to use.
So I want to check if a referer to my site CONTAINS a certain variable that I will assign and if it does, do something different than if it doesnt.

Example:

If the referer to my site contains google.com I want to be able to just set the contains to check for "google" and then go elsewhere if it does contain that.

How do I check if a referer just CONTAINS something, instead of having to put in the entire url.

Hopefully that makes sense.

Thanks in Advance!
 
Attempt to find the position of 'google.com' by using function strpos.

Code:
$pos = strpos($string, 'google.com');

if ( $pos === false )
{
print "Not found";
}

if ( $pos !== false )
{
print "Found";
}
Yes, we are using and extra =
 
Got it. Had to modify the above code a bit for my script. But it works. THANK YOU!
 
Last edited:
this is what i use:

HTML:
if 
(substr((trim($_SERVER['HTTP_REFERER'])),0,22)=="http://www.google.com/")
{
do this
}

replace the 22 with the number of characters, so http://google would be 13
 
Back
Top