Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Feb 2004
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 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
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    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



  • #3
    Regular Coder
    Join Date
    Feb 2004
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts
    works perfectly.

    thank you!
    steve

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Feb 2004
    Posts
    111
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sounds reasonable. do you have a link that explains how sessions can be used to track referrers?

    thanks,
    steve


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •