prepare("INSERT INTO bunks (name, owner, contact, location) VALUES (?, ?, ?, ?)"); $stmt->execute([$name, $owner, $contact, $location]); $_SESSION['notification'] = ['text' => 'Bunk added successfully!', 'type' => 'success']; } catch (PDOException $e) { $_SESSION['notification'] = ['text' => 'Error adding bunk: ' . $e->getMessage(), 'type' => 'danger']; } } else { $_SESSION['notification'] = ['text' => 'Bunk name is required.', 'type' => 'warning']; } header("Location: bunks.php"); exit; } if (isset($_SESSION['notification'])) { $notification = $_SESSION['notification']; unset($_SESSION['notification']); } try { $db = db(); $stmt = $db->query("SELECT id, name, owner, contact, location, created_at FROM bunks ORDER BY created_at DESC"); $bunks = $stmt->fetchAll(); } catch (PDOException $e) { $bunks = []; $notification = ['text' => 'Error fetching bunks: ' . $e->getMessage(), 'type' => 'danger']; } ?> Bunk Management

Bunk Management

Name Owner Contact Location Created Actions
No bunks found. Add one to get started!