Mini Kabibi Habibi

Current Path : C:/xampp/htdocs/ict_schedule/
Upload File :
Current File : C:/xampp/htdocs/ict_schedule/create_user.php

<?php
// create_user.php — run once to create admin user or reset password

include 'includes/db.php'; // make sure this file sets up $pdo correctly

$username = "admin";          // Change username if you want
$password = "ictunit1969";    // Change password if you want

// Hash password securely
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);

try {
    // Check if user already exists
    $stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
    $stmt->execute([$username]);
    $existingUser = $stmt->fetch();

    if ($existingUser) {
        // User exists, update password
        $stmt = $pdo->prepare("UPDATE users SET password = ? WHERE username = ?");
        $stmt->execute([$hashedPassword, $username]);
        echo "✅ User updated successfully.";
    } else {
        // Insert new user
        $stmt = $pdo->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
        $stmt->execute([$username, $hashedPassword]);
        echo "✅ User created successfully.";
    }
} catch (PDOException $e) {
    echo "❌ Error: " . $e->getMessage();
}