19 lines
597 B
PHP
19 lines
597 B
PHP
<?php
|
|
require 'koneksi.php';
|
|
$c = getConnection();
|
|
|
|
$sql = "CREATE TABLE IF NOT EXISTS users (
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
username VARCHAR(50) NOT NULL UNIQUE,
|
|
password VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
PRIMARY KEY (id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";
|
|
$c->query($sql);
|
|
|
|
$passwordHash = password_hash('admin123', PASSWORD_DEFAULT);
|
|
$insert = "INSERT IGNORE INTO users (username, password) VALUES ('admin', '$passwordHash')";
|
|
$c->query($insert);
|
|
|
|
echo 'Users table created and admin user inserted.';
|