Hello,
I would like to log all surfing activities of the user into a MySql database. These surfing activities are done within password protected pages that use sessions. The kind of surfing activities I would like to log include the user's username, password, keywords searched, date, time, etc.
Since there are many password protected pages & the user may be browsing from one page to another, I do not know how to log all the information efficiently. I've written a code to log the surfing activities but it doesn't make sense to insert this code on every single page. My code is below.
Is there a way to put this code only on 1 page & track the user's activities based on sessions or something like that?
Here's how my sessions look like:-
$_SESSION['passwordprotect'] = mysql_result($result,0,"id");
Here's my code for the log files:-
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<?PHP
function ConnectDB(){
$username="abc123";
$password="abc123";
$database="abc123";
$host="localhost";
$conn = mysql_connect("$host","$username","$password") or die('Could not connect: ' . mysql_error());
mysql_select_db($database) or die('Could not select database');
return $conn;
}
function WriteLog(){
$query="INSERT INTO logs SET date=CURDATE(), time=CURTIME()";
$results=mysql_query($query);
}
$conn=ConnectDB();
WriteLog();
$conn->close;
?>
</body>
</html>