...

View Full Version : check first few chars of a var



se4b4ss
02-26-2004, 10:13 PM
i am working on checking referrer pages. i don't want to send info to the db if $_SERVER['HTTP_REFERER'] starts with "http://www.texascontractorratings.com" (ie i referred the user to myself.) how do i accomplish this?

thanks in advance,
steve

JohnKrutsch
02-26-2004, 10:37 PM
I can thing of a bunch of different ways to accomplish this, here is one:



$me="http://www.texascontractorratings.com";
if(substr($_SERVER['HTTP_REFERER'],0,strlen($me)) != $me){
//do your stuff

}

se4b4ss
02-26-2004, 11:04 PM
works perfectly.

thank you! :thumbsup:
steve

missing-score
02-26-2004, 11:33 PM
Please bear in mind that referer is not always available, and many people (like myself) dont allow the information to be sent for security and privacy reasons. You may wish to look into an alternative to checking referer information, such as sessions.

se4b4ss
02-27-2004, 01:35 AM
sounds reasonable. do you have a link that explains how sessions can be used to track referrers?

thanks,
steve



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum