SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Logging where a visitor came from

    I'm working on a counter script that generates stats about how many hits a site has, and at what timeperiodes , and what browserversion etc etc.

    It is a php file, imbedded in a normal html page through image tags. So something like this :
    Code:
    <img src="http://www.mysite.com/counter.php">
    Most of it is working, but I'm kinda stuck at the part where I want to log from what other site the visitors came from.

    the data flow is like this:

    [1: some other site that has links to page (2) ] -> [2: a html page with my counter embedded] -> [3:my counter.php that loads whenever (2) is loaded]

    I tried to use getenv("HTTP_REFERER" ) on my counter (3) , but this only shows the url of (2) , so the html page that carries the counter.

    I cant use this method on (2) because this is a html page. (I'm making this counter for some friends, and they just have simpel html pages and cant switch to php)

    Now.. is there some way that the counter script can actually find out what the url was of (1), aka the site where the visitors where before they came to the site ? It should go back two steps in time, and I somehow doubt its possible.

    [edit] copied something wrong, it said HTTP_HOST first but in the script i already used HTTP_REFERER in fact, sorry for the confusion :s

  2. #2
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    $_SERVER['HTTP_REFERER']
    John

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry, that was what I meant in fact, have corrected my first post now

  4. #4
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm... then instead of using "<img...>" why not use "<?php include('counter.php'); ?>" ?
    John

  5. #5
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because the pages that contain the counter are only html pages. And I assumed <img> tags where the best, if not the only way to embed a remotly hosted php file.

  6. #6
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are two different things your could do. In your .htaccess file, you can tell the PHP parser to parse .html pages, or you could rename your .html files to .php.

    However, I would probably go the route of the .htaccess file.

    Unfortunately, it has been forever that I have done that, so I would search the site for the way to do it.
    John

  7. #7
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm ok thnx

    not sure if that will solve everything though but i'll have a look


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
  •