Page 1 of 1

How to create log file?

Posted: Thu Nov 08, 2012 8:08 pm
by holy24
Hi,

I have created a web application, however I need to create a log file that will capture the following information:
1. User login id and what is the date & time they login
2. What kind of operations the users use (eg. INSERT/UPDATE) on which records and which tables in the database, and also who is the user that create/update the data.

I have no ideas at all how to create the log file, can someone please kindly guide me.

Thanks.

Re: How to create log file?

Posted: Thu Nov 08, 2012 11:22 pm
by MeroD
The easiest way to get started is to create ON INSERT, ON UPDATE triggers that write details of all changes to an audit (activity) table.

http://www.sitepoint.com/how-to-create-mysql-triggers/
http://dev.mysql.com/doc/refman/5.5/en/ ... yntax.html

Re: How to create log file?

Posted: Thu Nov 15, 2012 7:08 pm
by holy24
Hi,

I have been reading the guides on trigger but really no idea what does it means. Is there any other way to create log file as I am quite new to programming? Thanks.

I have already created a web application. So when user login to the web, they can create a record and upon submitting, the user data will be capture into a log file as mentioned below:

1. Which record the user INSERT or UPDATE
2. Their username
3. The date and time that the user INSERT or UPDATE
4. What type of operation (eg. INSERT or UPDATE)


Create.php

<form name="form1" method="post" action="create2.php">
<table border="1" >
<tr>
<td><b>Name:</b></td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td><b>Department:</b></td>
<td><td><input type="text" name="department"></td>
</tr>
</table>


Create2.php

<?php

include 'connectdb.php';
$name=$_POST['name'];
$department=$_POST['department'];

mysql_query ("INSERT INTO table_name (name, department) VALUES ('$name', '$department')");

?>