PDO::ERRMODE_EXCEPTION]); // Rewrite db/config.php $configContent = " PDO::ERRMODE_EXCEPTION,\n" . " PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,\n" . " ]);\n" . " }\n" . " return \$pdo;\n" . "}\n"; file_put_contents(__DIR__ . '/db/config.php', $configContent); header('Location: install.php?step=4'); exit; } catch (Exception $e) { $error = 'Database Connection Failed: ' . $e->getMessage(); } } elseif ($step === 4) { require_once __DIR__ . '/db/config.php'; $username = $_POST['username'] ?? ''; $password = $_POST['password'] ?? ''; if (empty($username) || empty($password)) { $error = 'Please provide both username and password.'; } else { try { $pdo = db(); $pdo->exec("CREATE TABLE IF NOT EXISTS users ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"); $hash = password_hash($password, PASSWORD_DEFAULT); $stmt = $pdo->prepare("INSERT INTO users (username, password) VALUES (:username, :password) ON DUPLICATE KEY UPDATE password = :password"); $stmt->execute(['username' => $username, 'password' => $hash]); header('Location: install.php?step=5'); exit; } catch (Exception $e) { $error = 'Failed to create user: ' . $e->getMessage(); } } } elseif ($step === 5) { file_put_contents(__DIR__ . '/.installed', date('Y-m-d H:i:s')); file_put_contents(__DIR__ . '/install.lock', date('Y-m-d H:i:s')); header('Location: login.php'); exit; } } ?>
Welcome to the Hospital Queue Center installation wizard. This will set up your environment, configure the database variables, and create your super admin account so you are ready to go.
The installation has been successfully completed. Your database is set up and the super admin account is ready.