MINI
C:
/
xampp
/
htdocs
/
vot
/
Upload File:
files >> C:/xampp/htdocs/vot/vote.php
<?php session_start(); include "config.php"; if(!isset($_SESSION['nik'])){ header("Location:index.php"); exit; } $nik = $_SESSION['nik']; $cek = mysqli_fetch_assoc(mysqli_query($conn,"SELECT has_voted FROM voters WHERE nik='$nik'")); // ✅ JIKA SUDAH VOTING → OTOMATIS PINDAH KE HASIL if($cek['has_voted']==1){ header("Location: result.php"); exit; } $candidates = mysqli_query($conn,"SELECT * FROM candidates"); ?> <!DOCTYPE html> <html lang="id"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Pilih Kandidat</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> <style> body{ background:#f5f5f5; } .card-candidate{ border-radius:15px; box-shadow:0 4px 10px rgba(0,0,0,0.12); } .photo-candidate{ width:100%; max-height:220px; /* ✅ MODEL AWAL */ object-fit:contain; } .btn-vote{ font-size:18px; font-weight:bold; } </style> </head> <body> <div class="container py-4"> <div class="text-center mb-4"> <h4 class="fw-bold">🗳 PEMILIHAN KETUA RT 28</h4> <small class="text-muted">Silakan pilih salah satu kandidat</small> </div> <div class="row g-3"> <?php while($c=mysqli_fetch_assoc($candidates)){ ?> <div class="col-12"> <div class="card card-candidate p-3 text-center"> <!-- ✅ FOTO MODEL AWAL --> <img src="<?= $c['photo'] ?>" class="photo-candidate img-fluid rounded mb-3"> <h5 class="fw-bold"><?= $c['name'] ?></h5> <form method="post" action="submit_vote.php" onsubmit="return confirm('Yakin memilih <?= $c['name'] ?> ?')"> <input type="hidden" name="id" value="<?= $c['id'] ?>"> <button class="btn btn-success w-100 mt-3 btn-vote"> ✅ PILIH </button> </form> </div> </div> <?php } ?> </div> </div> </body> </html>
Copyright ©2021 || Defacer Indonesia