prepare("INSERT INTO sleep_sessions (start_time, end_time, rating) VALUES (?, ?, ?)"); $stmt->execute([$start_time, $end_time, $rating]); header('Location: index.php?success=1'); exit; } catch (PDOException $e) { die("Error saving session: " . $e->getMessage()); } } else { header('Location: index.php?error=missing_fields'); exit; } } else { header('Location: index.php'); exit; }