This commit is contained in:
2025-11-12 11:15:47 +01:00
parent a77cf5f9df
commit 2171cc3cfb
2 changed files with 35 additions and 0 deletions

28
functions/logging.php Normal file
View File

@@ -0,0 +1,28 @@
<?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;
}
}