<?php
include '../includes/db.php';

$full_name = "System Administrator";
$email = "admin@uol.edu.pk";
$cnic = "0000000000000";
$phone = "00000000000";
$password = "admin123"; // Default password
$role = "admin";

// Check if admin exists
$check = $conn->query("SELECT id FROM users WHERE email='$email'");
if ($check->num_rows == 0) {
    $hashed_password = password_hash($password, PASSWORD_DEFAULT);
    $sql = "INSERT INTO users (full_name, email, cnic, phone, password, role) 
            VALUES ('$full_name', '$email', '$cnic', '$phone', '$hashed_password', '$role')";
    
    if ($conn->query($sql) === TRUE) {
        echo "Admin user created successfully.<br>";
        echo "Email: $email<br>";
        echo "Password: $password<br>";
    } else {
        echo "Error creating admin: " . $conn->error;
    }
} else {
    echo "Admin user already exists.";
}
?>
