prepare("SELECT * FROM tasks WHERE id = ?"); $stmt->execute([$task_id]); $task = $stmt->fetch(); if (!$task) { header('Location: app.php'); exit; } // Fetch candidates for the dropdown $stmt = $pdo->query("SELECT id, name FROM candidates"); $candidates = $stmt->fetchAll(); // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_task'])) { $task_name = $_POST['task_name'] ?? ''; $candidate_id = $_POST['candidate_id'] ?? null; $due_date = $_POST['due_date'] ?? null; $status = $_POST['status'] ?? 'To Do'; $description = $_POST['description'] ?? ''; if (!empty($task_name) && !empty($candidate_id)) { try { $stmt = $pdo->prepare("UPDATE tasks SET task_name = ?, candidate_id = ?, due_date = ?, status = ?, description = ? WHERE id = ?"); $stmt->execute([$task_name, $candidate_id, $due_date, $status, $description, $task_id]); header('Location: app.php'); exit; } catch (PDOException $e) { error_log("Error updating task: " . $e->getMessage()); } } } ?> Edit Task

Edit Task

Cancel