trumpoikot
Enthusiast
how to create activity log using php
$_SESSION superglobal to track the current user's session. You can then use this information to log the user's activities.INSERT statement to add a new row to the activity log table.date() function to get the current date and time.session_start();
// Get the current user's session ID
$user_id = session_id();
// Get the current date and time
$date_time = date('Y-m-d H:i:s');
// Insert a new row into the activity log table
$sql = "INSERT INTO activity_log (date_time, user_id, activity_description) VALUES ('$date_time', '$user_id', 'User created a new record')";
mysqli_query($conn, $sql);