Page 1 of 1
I need help to track the user action
Posted: Tue Mar 16, 2010 7:48 am
by tamilmani
Hi Dudes,
I have to track the users action like as select , update , deletion , login and logut .... etc
I have to trach each the action and store into database .
Please any one help to me .
Regards
Tamilani Mohan

Re: I need help to track the user action
Posted: Tue Mar 16, 2010 8:22 am
by AbraCadaver
You can write a wrapper function for your queries that inserts the user action in a histories table.
Re: I need help to track the user action
Posted: Tue Mar 16, 2010 8:28 am
by greyhoundcode
I often use the Kohana framework which already has
logging facilities:
Code: Select all
Kohana::log('info', "User $userID ($username) logged in at " . date());
Of course, this writes to a text-based log file rather than a database, but the principal holds good. Nor would you need a framework's implementation, it would be very easy to make your own.
Either that, or what AbraCadaver said

Re: I need help to track the user action
Posted: Tue Mar 16, 2010 8:39 am
by tamilmani
please give me some sample code ......
Re: I need help to track the user action
Posted: Tue Mar 16, 2010 9:13 am
by AbraCadaver
tamilmani wrote:please give me some sample code ......
Code: Select all
function my_query($query) {
$result = mysql_query($query);
$action = mysql_real_escape_string($query);
$userid = mysql_real_escape_string($_SESSION['userid']);
mysql_query("INSERT INTO history (`action`, `userid`, `updated`) VALUES ('$action', '$userid', NOW())");
return $result;
}