prepare("INSERT INTO tasks (task, priority, due_date) VALUES (?, ?, ?)"); if ($stmt === false) { die('Prepare failed: ' . htmlspecialchars($conn->error)); } $stmt->bind_param('sss', $task, $priority, $due_date); $stmt->execute(); $stmt->close(); } } // Mark task as completed if (isset($_GET['complete'])) { $id = intval($_GET['complete']); $stmt = $conn->prepare("UPDATE tasks SET is_completed = 1 WHERE id = ?"); if ($stmt === false) { die('Prepare failed: ' . htmlspecialchars($conn->error)); } $stmt->bind_param('i', $id); if (!$stmt->execute()) { die('Execute failed: ' . htmlspecialchars($stmt->error)); } $stmt->close(); } // Edit task if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['edit_task_id'])) { $task_id = $_POST['edit_task_id']; $new_task = $_POST['edit_task']; $stmt = $conn->prepare("UPDATE tasks SET task = ? WHERE id = ?"); $stmt->bind_param('si', $new_task, $task_id); $stmt->execute(); $stmt->close(); } // Delete task if (isset($_GET['delete'])) { $id = intval($_GET['delete']); $stmt = $conn->prepare("DELETE FROM tasks WHERE id = ?"); $stmt->bind_param('i', $id); $stmt->execute(); $stmt->close(); } // Retrieve all tasks $result = $conn->query("SELECT * FROM tasks ORDER BY created_at DESC"); ?> To-Do List

To-Do List

Add Task

View / Edit Tasks

Completed Tasks

close(); ?>