prepare("SELECT * FROM candidates WHERE id = ?"); $stmt->execute([$candidate_id]); $candidate = $stmt->fetch(); if (!$candidate) { header('Location: index.php'); exit; } // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_candidate'])) { $name = $_POST['name'] ?? ''; $email = $_POST['email'] ?? ''; $phone = $_POST['phone'] ?? ''; $status = $_POST['status'] ?? 'Applied'; $notes = $_POST['notes'] ?? ''; if (!empty($name) && !empty($email)) { try { $stmt = $pdo->prepare("UPDATE candidates SET name = ?, email = ?, phone = ?, status = ?, notes = ? WHERE id = ?"); $stmt->execute([$name, $email, $phone, $status, $notes, $candidate_id]); header('Location: index.php'); exit; } catch (PDOException $e) { error_log("Error updating candidate: " . $e->getMessage()); } } } ?>