ÿØÿà JFIFÿØÿà JFIF ÿØÿà JFIFÿØÿà JFIF ÿþ$
<?php
session_start();
// Secure session settings
ini_set('session.cookie_httponly', 1);
if (isset($_SERVER['HTTPS'])) {
ini_set('session.cookie_secure', 1);
}
session_regenerate_id(true);
include('config.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<?php include('nav.php'); ?>
<br>
<br>
<br>
<br>
<br>
<br>
<section class="center" style="margin-top: 4rem;">
<!-- Optional: Title or Search Link -->
</section>
<main class="container">
<?php
// ================================
// Pagination Logic (SAFE)
// ================================
$results_per_page = 10;
// Get current page securely
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
if ($page < 1) $page = 1;
// Count total results safely
$count_query = $conn->prepare("SELECT COUNT(*) FROM registration");
$count_query->execute();
$count_query->bind_result($number_of_results);
$count_query->fetch();
$count_query->close();
$number_of_pages = ceil($number_of_results / $results_per_page);
$page_first_result = ($page - 1) * $results_per_page;
// Fetch paginated results securely
$stmt = $conn->prepare("SELECT Id, Childsname, Image, stage_two_vote FROM registration ORDER BY stage_two_vote DESC LIMIT ?, ?");
$stmt->bind_param("ii", $page_first_result, $results_per_page);
$stmt->execute();
$result = $stmt->get_result();
$con = $result->fetch_all(MYSQLI_ASSOC);
$stmt->close();
// Define current stage safely (if not set elsewhere)
$current_stage = isset($current_stage) ? (int)$current_stage : 0;
?>
<section>
<div class="row"><br>
<?php foreach($con as $cons): ?>
<div class="col l3 m6 s12 center" style="font-family: Trebuchet MS;">
<div class="card z-depth-1 center hoverable" style="padding-bottom: 40px; border-radius: 15%;">
<br>
<img src="<?= htmlspecialchars($cons['Image'], ENT_QUOTES, 'UTF-8') ?>"
class="avatar"
style="object-fit:contain; border-radius: 20%; width: 60%; height:250px"
alt="Contestant Image">
<h6 class="center" style="margin: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #000000a4; font-weight: bold;">
<?= htmlspecialchars($cons['Childsname'], ENT_QUOTES, 'UTF-8') ?>
</h6>
<div style="font-weight: bold; color: #FCB900; font-size: 1.4rem;">
<?= (int)$cons['stage_two_vote'] ?> Votes
</div>
<?php
$contestantId = (int)$cons['Id'];
switch ($current_stage) {
case 0:
$action = "notyet.php?id=$contestantId";
break;
case 1:
$action = "voter1.php?id=$contestantId";
break;
case 2:
$action = "voter2.php?id=$contestantId";
break;
case 3:
$action = "voter3.php?id=$contestantId";
break;
default:
$action = "notyet.php";
}
?>
<form action="<?= htmlspecialchars($action, ENT_QUOTES, 'UTF-8') ?>" method="POST">
<input type="hidden" name="id" value="<?= $contestantId ?>">
<input type="submit" name="vote" class="btn btno z-depth-0" value="View">
</form>
</div>
</div>
<?php endforeach; ?>
</div>
</section>
</main>
<style>
.btno {
background-color: #560280;
color: white;
border-radius: 10px;
}
.btno:hover {
color: #560280;
background-color: white;
text-decoration: none;
font-weight: bold;
border: solid 1px #FCB900;
border-radius: 10px;
}
</style>
<br>
<?php include('footer.php'); ?>
</body>
</html>
ÿØÿà JFIF ÿþ$
ÿØÿà JFIF ÿþ$
ÿÂ