PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
1. User logs in
2. Every time a user clicks a link you insert into or update a table in the database with the current page, and a timestamp.
You can then also do things like check how many users are on your site (users active in the last 5 mins), check which pages are visited most frequently and check access times.... pretty useful thing to do.
I know the basics of php/mysql, I'm still learning though, so yes I do a little scripting, but it's mostly retrieving/ submitting date to and from the db.
Can anyone put together a bit of a sample? Or even maybe explain in plain english and I can give it a crack scripting it.
<?php
/* Assuming user data was saved in the following fashion... */
$userid = $_SESSION['userid']; //<-- retrieve user ID from session variables
/* Query database & add to counter */
mysql_query("UPDATE user_table SET last_access_time = ".time()." WHERE user_id = ".$userid);
?>
$date = date ( 'g:i A l, F j Y.' );
$query_user = "UPDATE registered_mem SET last_access_time = '$date' WHERE username = '$username'";
$result = mysql_query($query_user, $db_conn) or die(mysql_error());
Just used the date(); function instead of time();.
Works great!
Thanks for the help everyone.