exec("CREATE TABLE IF NOT EXISTS growth_entries ( id INT PRIMARY KEY AUTO_INCREMENT, entry_date DATE NOT NULL, mood VARCHAR(255) NOT NULL, notes TEXT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP )"); } catch (PDOException $e) { die("Database setup failed: " . $e->getMessage()); } // --- FORM HANDLING --- if ($_SERVER['REQUEST_METHOD'] === 'POST') { $mood = $_POST['mood'] ?? ''; $notes = $_POST['notes'] ?? ''; $entry_date = date('Y-m-d'); if (!empty($mood)) { try { $stmt = $pdo->prepare("INSERT INTO growth_entries (entry_date, mood, notes) VALUES (?, ?, ?)"); $stmt->execute([$entry_date, $mood, $notes]); header('Location: index.php?saved=1'); exit; } catch (PDOException $e) { // In a real app, log this error instead of dying die("Failed to save entry: " . $e->getMessage()); } } } // --- DATA FETCHING --- $entries = []; try { $stmt = $pdo->query("SELECT * FROM growth_entries ORDER BY created_at DESC"); $entries = $stmt->fetchAll(); } catch (PDOException $e) { // In a real app, you might want to display a friendly error to the user error_log("Failed to fetch entries: " . $e->getMessage()); } // --- METADATA --- $projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? 'Track your daily growth and progress.'; $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; ?> Daily Growth Tracker

Daily Growth Tracker

Your personal space to reflect and grow, one day at a time.

How was your day?

Past Entries

No entries yet. Add one above to get started!