Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 16th, 2006, 1:15 PM   #1
k4pil
Programmer
 
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4 k4pil is on a distinguished road
Creating audit trail using php

Hi there.

I have created a website which requires users to have an appropriate username and password to enter. However, the next step is that each time a user logs a record is made on the mySql database.

Also, would it be possible to record on the same database which files from my server this user has accessed??

Just need some direction, iv searched the web and looked in the library, but nothing as of yet.

Thanks in advance
k4pil is offline   Reply With Quote
Old Feb 16th, 2006, 1:22 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Anything you can detect the user doing you can log. You wouldn't want to keep a list of files in the user table. It would be better to keep a list of files (another table) with the user's id (a unique key, I presume) as part of the record. Then you could make a joined query if you wanted to see the list for a given user. Stuff like that. Same with login records.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 16th, 2006, 1:36 PM   #3
k4pil
Programmer
 
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4 k4pil is on a distinguished road
Cheers DaWei, but what do i need to know in order to get something like that working.

Also, the users do have a unique id that i could use in some new table e.g.usersActivities(activityLog, userID,time,activity) here activityLog would be unique. That look ok?
k4pil is offline   Reply With Quote
Old Feb 16th, 2006, 1:50 PM   #4
NFreak
Newbie
 
Join Date: Feb 2006
Posts: 8
Rep Power: 0 NFreak is on a distinguished road
Send a message via AIM to NFreak Send a message via Yahoo to NFreak
You can make a footer to run a script at the bottom of every page that updates a table in the database and keeps track of how many times each page was viewed.
__________________
http://nfreak.net/
NFreak is offline   Reply With Quote
Old Feb 16th, 2006, 2:06 PM   #5
k4pil
Programmer
 
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4 k4pil is on a distinguished road
Ok. So if i have a table like
usersActivities(activityLog, userID,time,page)

I can add to this databse everytime a page is accessed because there is a script at the bottom, makes sense.

Script would be something like
INSERT INTO UsersActivities VALUES ('', $userID,'', $pageTitle

Well something like that?
Ill give it a go
k4pil is offline   Reply With Quote
Old Feb 16th, 2006, 2:10 PM   #6
NFreak
Newbie
 
Join Date: Feb 2006
Posts: 8
Rep Power: 0 NFreak is on a distinguished road
Send a message via AIM to NFreak Send a message via Yahoo to NFreak
Quote:
Originally Posted by k4pil
Ok. So if i have a table like
usersActivities(activityLog, userID,time,page)

I can add to this databse everytime a page is accessed because there is a script at the bottom, makes sense.

Script would be something like
INSERT INTO UsersActivities VALUES ('', $userID,'', $pageTitle

Well something like that?
Ill give it a go
I would make a table that has a field for every page you want information logged in. Then there would be a record for each member on your site. Then when a member views a page, you have it update the table where member = $userID and pagetitle = $pageTitle.
__________________
http://nfreak.net/
NFreak is offline   Reply With Quote
Old Feb 16th, 2006, 3:18 PM   #7
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by NFreak
I would make a table that has a field for every page you want information logged in.
Are you saying that you should have a table with a column for each page? Because that isn't really a very good solution. k4pil's table seems a lot better, though I have no idea what the "activityLog" field is for. And I think he needs a unique ID for each row in his log.
Arevos is offline   Reply With Quote
Old Feb 16th, 2006, 3:34 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Arevos is correct. Whether it turns out to be overkill or not, I generally have a unique ID in every table. For instance, if I had a database with a bunch of customers, each of which could have multiple orders, my orders table would have a unique ID for each row, a product ID for each product included in the order, and a customer ID to relate the order back to the customer. The product ID would relate back to the product table.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 16th, 2006, 4:39 PM   #9
k4pil
Programmer
 
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4 k4pil is on a distinguished road
Well mu activityLog was a unique id for each activity i guess...well it made sense when i wrote it and kinda still does
k4pil is offline   Reply With Quote
Old Feb 16th, 2006, 10:42 PM   #10
NFreak
Newbie
 
Join Date: Feb 2006
Posts: 8
Rep Power: 0 NFreak is on a distinguished road
Send a message via AIM to NFreak Send a message via Yahoo to NFreak
Quote:
Originally Posted by Arevos
Are you saying that you should have a table with a column for each page? Because that isn't really a very good solution. k4pil's table seems a lot better, though I have no idea what the "activityLog" field is for. And I think he needs a unique ID for each row in his log.
Well if he only wanted to log activity on certain pages, then my solution would probably be a better idea, but I'm assuming he wants every page on his site logged, so yes, my idea was stupid.

I'm new to MySQL. I've only been using it for maybe a month. >.<
__________________
http://nfreak.net/
NFreak is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:09 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC