user/page tracking

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • junior29
    New Member
    • Feb 2008
    • 5

    user/page tracking

    Hi,

    I just wondered if anyone could help me at all. I'm doing a piece of coursework building a social network (which is getting there!), we are supposed to add an administration element to include tracking of access of pages by registered users to include their username, date and time of access, browser used, ip address of user and which page was accessed. This is to be put into a report to then be able to be sorted by page, user and by browser.

    I'm fairly new to PHP programming and have used many hours online trying to find tutorials to guide me through. This has stumped me at how to request all this information into an array and being able to store in a db or file then echo this out with the ability to sort it. We have restrictions on our server to write to a txt file, though I can write to db fine. I've found resources that show me individual elements like getting the ip address etc, but I'm yet to find something that helps me to get all this information. I think I'm struggling with how to put it all together.

    The site itself uses sessions for authentication.

    I hope someone can help, many thanks in advance.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    This is a site for programmers helping programmers, not a code factory. So, if you want our members to help you, show the code you have developed so far and we will have a look and see what is wrong.

    And do not forget to enclose any code you show, within the appropriate code tags!

    Ronald

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      And welcome to theScripts!

      Comment

      • junior29
        New Member
        • Feb 2008
        • 5

        #4
        Hi,

        ok, i've already built the social network site that has a register/login process, upload image system, edit profile area, private messaging, open forum etc..

        the part im stuck is where to start with tracking the members only pages by which user access them, when, etc... ive been looking for tutorials that show how to extract the IP address or browser information, though individually not together so that it could be made into a report..

        im not sure where to start with this, whether there needs to be some tracking function with the pages?? ive searched for tracking etc and just is confusing me..

        not asking for code, just a bit stuck as to how to approach this..

        Comment

        • nathj
          Recognized Expert Contributor
          • May 2007
          • 937

          #5
          Hi,

          You can get teh users IP address via getenv('REMOTE_ ADDR'), take a look at the environment variables under php - run a page with phpinfo() on it and you'll see them all. This will show you wat information you can access using getenv. you should be able to get everything you need.

          If you are going to rack the activiy of users once they are logged in you really needto use a DB - it will make the reporting side of your project so much easier.

          I would, at the start of every page, check if this is a logged in user. If it is then retreive the data you want and store it to the database.

          That's the basic logice I would use to approach this problem.

          When it comes to reporting it simply means retrieving the data from the database and with the desired order set. The user can then re-set the order and you can reorder the data and display it again - this could be done very nicely with AJAX.

          I hope this gives you some pointers in the right direction.

          Cheers
          nathj

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            I guess you haven't looked into Dennis Pallett's (famous) article about tracking users (ip address, page, referrer, date/time, useragent, remote host) and all in PHP at Track Your Visitors, Using PHP

            Ronald

            Comment

            • junior29
              New Member
              • Feb 2008
              • 5

              #7
              Thanks, that looks very helpful!

              Our server has restrictions with writing to txt files but can easily change that aspect to work with a db using insert into!..

              Thank you.. i didn't see this amongst the hours of searching.. sometimes can look past things im sure i have many times..

              I'll see how i get on now with this.. thank you once again..

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #8
                Glad I could help out. See you next time.

                Ronald

                Comment

                • junior29
                  New Member
                  • Feb 2008
                  • 5

                  #9
                  Hi!

                  To update, the link helped a lot to structure the tracking, i've basically created a tracking file and included it on each page i wish to track, then stored the data in a db, which is working great

                  Just a quick question really... would there be any reason why it doesnt include the data of pages viewed using IE, netscape and safari?

                  I've just sat testing that its picking up from other browsers and it doesnt seem to add it from internet explorer, netscape and safari.. bit confused by that?? but does pick up firefox and opera!

                  Comment

                  • junior29
                    New Member
                    • Feb 2008
                    • 5

                    #10
                    Resolved! I had to change names and alter the length of the varchar in the database it now picks up every browser instead of just two...

                    Comment

                    • ronverdonk
                      Recognized Expert Specialist
                      • Jul 2006
                      • 4259

                      #11
                      That puzzled me, but I am glad you found it. See you around.

                      Ronald

                      Comment

                      Working...