Server error: The server encountered an error: " . $msg . "
\n"; closeHTML(); } // For use in pages that first display a form and then process it function switchToFormProcess($requireLogin = true) { if (empty($_POST) AND $requireLogin AND !isset($_SESSION['username'])) echo 'Ce formulaire ne sera pas accepté car il faut se connecter avant.
'; if (empty($_POST)) closeHTML(); if ($requireLogin AND !isset($_SESSION['username'])) userError("Vous devez être connecté·e pour effectuer cette action."); } function query($action, $table, $conditions = [], $column = NULL) { $query = match ($action) { 'select' => 'SELECT *', 'delete' => 'DELETE', }; $query .= " FROM $table"; foreach ($conditions as $key => $val) { if ($key === array_key_first($conditions)) $query .= " WHERE $key = :$key"; else $query .= " AND $key = :$key"; } $db = new PDO('sqlite:' . DB_PATH); $op = $db->prepare($query); foreach ($conditions as $key => $val) $op->bindValue(":$key", $val); $op->execute(); if (isset($column)) return array_column($op->fetchAll(PDO::FETCH_ASSOC), $column); return $op->fetchAll(PDO::FETCH_ASSOC); } function displayIndex() { ?>