<?php
// Assuming you have established a database connection
// Include necessary files and start session
require_once '../config.php';
session_start();

// Check if the user is logged in as a system admin
$connection = mysqli_connect($db_host, $db_user, $db_password, $db_name);

if (!isset($_SESSION['userType']) || $_SESSION['userType'] !== 'member') {
    header('Location: ../indexX.php');
    exit;
}

// Fetch the current credit count from the users table
$userId = $_SESSION['id']; // Assuming you have stored the user ID in the session
$query = "SELECT credits FROM users WHERE id = $userId";
$result = mysqli_query($connection, $query);

if ($result) {
    $row = mysqli_fetch_assoc($result);
    $creditCount = $row['credits'];
} else {
    // Handle database error
    $creditCount = 0; // Set the default credit count to 0
}

// Close the database connection
mysqli_close($connection);
include('../headerspecial.php');

?>

<!-- HTML Markup for the Dashboard -->
<!DOCTYPE html>
<html>
<head>
    <title>Zonal Representative Dashboard</title>
</head>
<body>
    <h1>Welcome to your Dashboard</h1>
    <h2>Credit Count: <?php echo $creditCount; ?></h2>

    <!-- Links for Nominee Upload -->
    <h3>Upload Nominee Information:</h3>
    <ul>
        <!--<li><a href="single_upload1.php">Single Upload</a></li>-->
        <li><a href="bulk_upload.php">Bulk Upload</a></li>
    </ul>
</body>
</html>
