Attendance
No users are currently online.
| Username | Login Time | Logout Time | IP Address |
|---|---|---|---|
| Still logged in'; ?> |
exec("CREATE TABLE IF NOT EXISTS attendance ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT NOT NULL, login_time DATETIME NOT NULL, logout_time DATETIME DEFAULT NULL, ip_address VARCHAR(45), FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); // Fetch online users $online_users_stmt = $pdoconn->prepare("SELECT u.username FROM attendance a JOIN users u ON a.user_id = u.id WHERE a.logout_time IS NULL"); $online_users_stmt->execute(); $online_users = $online_users_stmt->fetchAll(PDO::FETCH_ASSOC); // Fetch attendance history $history_stmt = $pdoconn->prepare("SELECT u.username, a.login_time, a.logout_time, a.ip_address FROM attendance a JOIN users u ON a.user_id = u.id ORDER BY a.login_time DESC"); $history_stmt->execute(); $history = $history_stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { die("Could not connect to the database :" . $e->getMessage()); } ?>
No users are currently online.
| Username | Login Time | Logout Time | IP Address |
|---|---|---|---|
| Still logged in'; ?> |