How to create log file?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

holy24
New php-forum User
New php-forum User
Posts: 6
Joined: Mon Sep 03, 2012 7:28 pm

How to create log file?

Postby holy24 » Thu Nov 08, 2012 8:08 pm

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.

MeroD
New php-forum User
New php-forum User
Posts: 53
Joined: Wed Oct 10, 2012 12:14 am

Re: How to create log file?

Postby MeroD » Thu Nov 08, 2012 11:22 pm

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

holy24
New php-forum User
New php-forum User
Posts: 6
Joined: Mon Sep 03, 2012 7:28 pm

Re: How to create log file?

Postby holy24 » Thu Nov 15, 2012 7:08 pm

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')");

?>


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 2 guests