SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2004
    Location
    montreal
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    if $_SERVER['HTTP_REFERER'] contains

    Hi,

    what's the proper code to write if the $_SERVER['HTTP_REFERER'] contains the words i chose?

    EX: if ($_SERVER['HTTP_REFERER'] contains "this word") {
    print "yes";
    } else {
    print "no";
    }

    thank you

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    ecuador
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $_SERVER['HTTP_REFERER'];
    #checks if some page came from the desired location.
    #ie
    if ($_SERVER['HTTP_REFERER'] == 'index.php')
    {
    echo 
    'You are allowed to continue.';
    }
    else
    {
    echo 
    'Acces denied';


  3. #3
    SitePoint Zealot
    Join Date
    Feb 2004
    Location
    montreal
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it has to be if it contains 'index.php' because if have multiple ?variable=word& in my url, and it's always changing....

  4. #4
    SitePoint Evangelist Daijoubu's Avatar
    Join Date
    Oct 2002
    Location
    Canada QC
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if (strpos($_SERVER['HTTP_REFERER'], 'stuff') !== false)
    {
        
    // Found
    }
        
    // Not found

    Speed & scalability in mind...
    If you find my reply helpful, fell free to give me a point


Bookmarks

Posting Permissions

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