This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcandidate_list.php
60 lines (49 loc) · 1.7 KB
/
candidate_list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
session_start();
if (!isset($_SESSION["username"])) {
header("Location: ../index.html");
exit();
}
require_once "./conn/db_connection.php";
?>
<!DOCTYPE html>
<html lang="en" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SK E-Voting System - Candidate List</title>
<link href="../frontend/css/output.css" rel="stylesheet">
</head>
<body class="bg-gray-100 p-8">
<h1 class="text-2xl font-bold mb-4 text-black">Candidate List</h1>
<hr><br>
<div id="candidateListContainer">
</div>
<script>
// Function to load candidate list
function loadCandidateList() {
var xhr = new XMLHttpRequest();
xhr.open('GET', './CdListLoader.php', true);
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
// Update the candidate list container with new data
document.getElementById('candidateListContainer').innerHTML = xhr.responseText;
console.log("Candidate list updated -->")
} else {
console.error('Error loading candidate list');
}
}
};
xhr.send();
}
// Check if current URL has #candidate-list
if (window.location.hash === '#candidate-list') {
// Load candidate list
loadCandidateList();
// Set interval to reload candidate list every 6 seconds
setInterval(loadCandidateList, 6000);
}
</script>
</body>
</html>