MINI
C:
/
xampp
/
htdocs
/
polling_rt - Copy
/
Upload File:
files >> C:/xampp/htdocs/polling_rt - Copy/dashboard.php
<?php session_start(); require '../inc/db.php'; if (!isset($_SESSION['admin_logged_in'])) { header('Location: login.php'); exit; } // reset votes if (isset($_GET['reset']) && $_GET['reset']=='1') { $mysqli->query('UPDATE candidates SET votes = 0'); $mysqli->query('TRUNCATE TABLE votes'); header('Location: dashboard.php?msg=reset'); exit; } $candidates = []; $res = $mysqli->query('SELECT * FROM candidates ORDER BY id'); while($r = $res->fetch_assoc()) $candidates[] = $r; ?> <!doctype html> <html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Dashboard Admin</title></head> <body> <h2>Admin Dashboard</h2> <p><a href="?reset=1" onclick="return confirm('Reset semua suara?')">Reset Semua Suara</a> | <a href="logout.php">Logout</a></p> <h3>Kandidat</h3> <ul> <?php foreach($candidates as $c): ?> <li><?= esc($c['name']); ?> - <?= (int)$c['votes']; ?></li> <?php endforeach; ?> </ul> </body></html>
Copyright ©2021 || Defacer Indonesia