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(); ?>
Please select your candidates carefully. Your vote is immutable once cast.