By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

user/page tracking

junior29
P: 5
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.
Feb 24 '08 #1
Share this Question
Share on Google+
10 Replies


ronverdonk
Expert 2.5K+
P: 4,258
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
Feb 24 '08 #2

Markus
Expert 5K+
P: 6,050
And welcome to theScripts!
Feb 24 '08 #3

junior29
P: 5
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..
Feb 28 '08 #4

nathj
Expert 100+
P: 938
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
Feb 28 '08 #5

ronverdonk
Expert 2.5K+
P: 4,258
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
Feb 28 '08 #6

junior29
P: 5
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..
Feb 28 '08 #7

ronverdonk
Expert 2.5K+
P: 4,258
Glad I could help out. See you next time.

Ronald
Feb 28 '08 #8

junior29
P: 5
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!
Mar 3 '08 #9

junior29
P: 5
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...
Mar 6 '08 #10

ronverdonk
Expert 2.5K+
P: 4,258
That puzzled me, but I am glad you found it. See you around.

Ronald
Mar 6 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.