log
This commit is contained in:
28
functions/logging.php
Normal file
28
functions/logging.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user