SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Check referer and give a message

    Hi all!

    I have been trying to find how to get the refering url to a page of my website, check if it's included on a txt file and then print a modal popup with a message. So, if you come from a friend url included on the txt it will welcomes you "You come from a friend's url" for example, and if not, then another msg will be printed.

    Someone knows? I have found codes for the different functions separately but don't know how to put them all together to do this.

    Thanks!

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Start by showing us what you have tried thus far AND what errors, if any, you are getting.

  3. #3
    SitePoint Member
    Join Date
    May 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes sorry, this is what I've tried and it reported me a 500 eror
    <?php
    if (ref.match(/^https?:\/\/([^\/]+\.)?friendsite\.com(\/|$)/i)) {
    alert("You came from a friend Website");
    else { alert("You came from a non friendly Webstie");
    }
    ?>
    Also, this code will just check if the referal matches just 1 specific address, bout I'd like to check more than just one. maybe getting them from a txt file?

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    51
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What you've posted is JavaScript, not PHP code...

  5. #5
    SitePoint Member
    Join Date
    May 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep! sorry, but it doesn't work anyway. does someone know any alternative for what I want to do? no matter php or java.
    thanks!


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
  •