Web Analytics Made Easy -
StatCounter check first few chars of a var - CodingForum

Announcement

Collapse
No announcement yet.

check first few chars of a var

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • check first few chars of a var

    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

  • #2
    I can thing of a bunch of different ways to accomplish this, here is one:

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


    Comment


    • #3
      works perfectly.

      thank you!
      steve

      Comment


      • #4
        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.
        PHP Weekly - A PHP Developers Resource
        PHP 5.1.4 and Ruby on Rails web hosting
        Moderator of PHP and Work offers and Requests
        Install Apache/PHP/MySQL
        (by marek_mar) | TinyPlugin Architecture

        Comment


        • #5
          sounds reasonable. do you have a link that explains how sessions can be used to track referrers?

          thanks,
          steve

          Comment

          Working...
          X