prepare("SELECT id FROM candidates WHERE election_id = ? AND user_id = ?"); $check->execute([$election_id, $user_id]); if ($check->fetch()) { die("User is already a candidate in this election."); } $stmt = $pdo->prepare("INSERT INTO candidates (id, election_id, position_id, user_id, party_name, manifesto, approved) VALUES (?, ?, ?, ?, ?, ?, TRUE)"); $stmt->execute([$id, $election_id, $position_id, $user_id, $party_name, $manifesto]); audit_log('Added candidate', 'candidates', $id); header("Location: ../manage_candidates.php?position_id=$position_id&success=1"); exit; } catch (Exception $e) { die($e->getMessage()); } }