diff --git a/assets/js/main.js b/assets/js/main.js index 3d1134e..b8801c0 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -37,13 +37,6 @@ document.addEventListener('DOMContentLoaded', function () { event.preventDefault(); const formData = new FormData(form); const data = Object.fromEntries(formData.entries()); - const votes = (data.category === 'beauty') ? beautyVotes : funnyVotes; - - // Add the individual vote numbers to the data object for the backend - data.website_number_1 = votes[0] || ''; - data.website_number_2 = votes[1] || ''; - data.website_number_3 = votes[2] || ''; - delete data.website_numbers; // remove the comma-separated string fetch('submit_vote.php', { method: 'POST', diff --git a/results.php b/results.php index 1aab1f0..4f0c0d4 100644 --- a/results.php +++ b/results.php @@ -13,8 +13,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $pdo = db(); $pdo->exec('TRUNCATE TABLE votes'); $message = 'All votes have been cleared.'; - } - else { + } else { if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']) { $error = 'Invalid password'; } @@ -26,67 +25,104 @@ if (isset($_GET['logout'])) { header('Location: results.php'); exit; } +?> + + +
+ + +$message
"; - } - // Database connection - require_once 'db/config.php'; - $pdo = db(); + + + - // Fetch results - $stmt = $pdo->query('SELECT category, website_number, COUNT(*) as votes FROM votes GROUP BY category, website_number ORDER BY category, votes DESC'); - $results = $stmt->fetchAll(PDO::FETCH_ASSOC); +No votes yet.
+ +No votes yet.
+ +