prepare("SELECT * FROM elections WHERE id = ?"); $stmt->execute([$id]); $election = $stmt->fetch(); if (!$election || $election['status'] !== 'Ongoing') { die("Election is not currently ongoing."); } // Check if already voted $check = $pdo->prepare("SELECT COUNT(*) FROM votes WHERE election_id = ? AND voter_id = ?"); $check->execute([$id, $user['id']]); if ($check->fetchColumn() > 0) { header("Location: view_results.php?id=$id&error=AlreadyVoted"); exit; } $positions = $pdo->prepare("SELECT * FROM positions WHERE election_id = ? ORDER BY sort_order ASC"); $positions->execute([$id]); $positions = $positions->fetchAll(); ?> Vote: <?= htmlspecialchars($election['title']) ?>

Please select your candidates carefully. Your vote is immutable once cast.

Select candidate(s)
prepare("SELECT c.*, u.name FROM candidates c JOIN users u ON c.user_id = u.id WHERE c.position_id = ? AND c.approved = TRUE"); $cStmt->execute([$pos['id']]); $candidates = $cStmt->fetchAll(); ?>

No candidates for this position.

By clicking "Cast My Vote", I acknowledge that my selection is final.