setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Set PDO to use buffered queries (good for single row results)
$conn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
} catch(PDOException $e) {
// Log the error and show a user-friendly message
error_log("Game Subdomain DB Connection Error: " . $e->getMessage());
http_response_code(500);
die("
Error: Could not connect to the game database. Please contact support.
");
}
// Generate CSRF token if not set
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
// --- Fetch User Balance ---
$current_balance = 0.00;
try {
// *** VERIFY COLUMN NAMES ***
$stmt = $conn->prepare("SELECT sWallet FROM subscribers WHERE sEmail = ? LIMIT 1");
$stmt->execute([$_SESSION['sEmail']]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if ($user) {
$current_balance = (float)$user['sWallet'];
} else {
// User not found in database, even though session says they are logged in
error_log("Game Subdomain: User '{$_SESSION['sEmail']}' not found in subscribers table.");
// Optionally, you could log them out or show an error
// For now, we'll just show 0 balance
}
} catch(PDOException $e) {
error_log("Game Subdomain Balance Fetch Error: " . $e->getMessage());
// Handle error gracefully, maybe show an error message in the UI
}
// --- Configuration ---
$available_bets = [50.00, 100.00, 200.00, 500.00, 1000.00];
define('DEFAULT_BET_AMOUNT', 50.00);
define('AVAILABLE_NUMBERS', [1, 2, 3, 4, 5, 6]);
define('WIN_PERCENTAGE', 30);
define('NUMBER_PICK_WIN_MULTIPLIER', 2);
// --- End Configuration ---
?>
Lucky Number Pick & Roll
Rolling Dice...
Lucky Number Pick & Roll
Your Balance:
₦
Entry Fee: ₦
Select Bet Amount:
Pick Your Number:
Selected: None
1
2
3
4
5
6
How to Play:
Step 1: Select your Bet Amount.
Step 2: Select one number from the grid (1-).
Step 3: Click the Roll Dice button.
The selected bet amount will be deducted from your balance.
Win: The die shows the number you picked. Win x your bet amount.
Lose: The die shows any other number. Lose your bet amount.