Files
lootjes/functions/logging.php
2025-11-12 11:15:47 +01:00

29 lines
834 B
PHP

<?php
// functions/logging.php
/**
* Logt een actie in de database.
*
* @param PDO $pdo PDO-verbinding
* @param string $gebruiker Gebruikersnaam
* @param string $actie Beschrijving van de actie
* @param string $extra Optioneel extra info
* @return bool true bij succes, false bij fout
*/
function log_action(PDO $pdo, string $gebruiker, string $actie, string $extra = ''): bool
{
try {
$stmt = $pdo->prepare(
"INSERT INTO log (gebruiker, actie, extra) VALUES (:gebruiker, :actie, :extra)"
);
return $stmt->execute([
':gebruiker' => $gebruiker,
':actie' => $actie,
':extra' => $extra
]);
} catch (PDOException $e) {
error_log("Logging fout: " . $e->getMessage());
return false;
}
}