prepare( "INSERT INTO notes (note_date, content) VALUES (?, ?) ON DUPLICATE KEY UPDATE content = VALUES(content)" ); $stmt->execute([$date_to_save, $content]); $message = 'Note saved successfully!'; } catch (PDOException $e) { // In a real app, log this error instead of showing it to the user $message = 'Error saving note: ' . $e->getMessage(); } } // Fetch existing note for the date $stmt = $pdo->prepare("SELECT content FROM notes WHERE note_date = ?"); $stmt->execute([$note_date]); $note = $stmt->fetch(); if ($note) { $note_content = $note['content']; } $formatted_date = date("l, F j, Y", strtotime($note_date)); ?> Note for <?= htmlspecialchars($formatted_date) ?>

My Diary

Back to Dashboard