<?php
include('config.php');

// Default admin user
$username = "cybervax";
$password = "admin123"; // You should change this password after first login
$hashed_password = password_hash($password, PASSWORD_DEFAULT);

// Check if user already exists
$check = $conn->prepare("SELECT id FROM users WHERE username = ?");
$check->bind_param("s", $username);
$check->execute();
$result = $check->get_result();

if ($result->num_rows == 0) {
    // Create user
    $stmt = $conn->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
    $stmt->bind_param("ss", $username, $hashed_password);
    
    if ($stmt->execute()) {
        echo "User created successfully!<br>";
        echo "Username: " . $username . "<br>";
        echo "Password: " . $password . "<br>";
        echo "Please <a href='login.php'>login</a> and change this password!";
    } else {
        echo "Error creating user: " . $conn->error;
    }
    
    $stmt->close();
} else {
    echo "User already exists! Please <a href='login.php'>login</a> instead.";
}

$check->close();
$conn->close();
?> 