Simple way to catch referer using javascript and PHP?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Emil
    Confirmed User
    • Feb 2007
    • 5658

    #1

    Simple way to catch referer using javascript and PHP?

    Lets say I want people to put a small javascript on their site. This javascript should "send" the referer-URL to one of my PHP-scripts on my server.

    How could this be done? All these webcounters use Javascript, can anyone plz explain how I can do this?
    Free 🅑🅘🅣🅒🅞🅘🅝🅢 Every Hour (Yes, really. Free ₿itCoins.)
    (Signup with ONLY your Email and Password. You can also refer people and get even more.)
  • redwhiteandblue
    Bollocks
    • Jun 2007
    • 2793

    #2
    You could do something simple like

    Code:
    <script language="Javascript" type="text/javascript">
    <!--
    var docRef = document.referrer
    docRef = encodeURIComponent(docRef) //URI encode the referrer string
    dummyPhpImg = new Image
    dummyPhpImg.src = '/yourserversidescript.php?REF=' + docRef
    //-->
    </script>
    Basically loads a dummy image object which is actually your php script, don't forget to send a header response as an img file at the of the script, it can be an empty 1x1 pixel image, doesn't matter as you're not going to display it. BTW you can add more parameters to the query string such as screen size, client time, etc.
    Interserver unmanaged AMD Ryzen servers from $73.00

    Comment

    • Emil
      Confirmed User
      • Feb 2007
      • 5658

      #3
      Thank you!
      Free 🅑🅘🅣🅒🅞🅘🅝🅢 Every Hour (Yes, really. Free ₿itCoins.)
      (Signup with ONLY your Email and Password. You can also refer people and get even more.)

      Comment

      Working...