<?php
session_start();
include 'db.php';

if (!isset($_SESSION['user_id'])) {
    header("Location: login.php");
    exit();
}

$id = $_SESSION['user_id'];
$result = $conn->query("SELECT balance FROM users WHERE id=$id");
$user = $result->fetch_assoc();
?>

<h1>Welcome to Cloud Mining!</h1>
<p>Your Balance: 💰 <?php echo number_format($user['balance'], 6); ?> coins</p>
<a href="mine.php">Start Mining</a> | 
<a href="withdraw.php">Withdraw</a> | 
<a href="mining_history.php">Mining History</a> | 
<a href="logout.php">Logout</a>
