36735-vm/db/user_seed.php
Flatlogic Bot d076708932 feat: Implement new design and features for the main page
- Redesigned the main page with a modern look and feel.
- Added search and filtering functionality for drills.
- Implemented pagination for browsing drills.
- Added the ability for users to mark drills as favorites.
2025-12-07 18:15:23 +00:00

49 lines
1.4 KiB
PHP

<?php
require_once __DIR__ . '/config.php';
try {
$pdo = db();
// Create users table
$pdo->exec("CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('admin', 'coach') NOT NULL DEFAULT 'coach',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)");
// Add sample users
$users = [
[
'name' => 'Admin User',
'email' => 'admin@example.com',
'password' => password_hash('password', PASSWORD_DEFAULT),
'role' => 'admin'
],
[
'name' => 'Coach User',
'email' => 'coach@example.com',
'password' => password_hash('password', PASSWORD_DEFAULT),
'role' => 'coach'
]
];
$stmt = $pdo->prepare("INSERT INTO users (name, email, password, role) VALUES (:name, :email, :password, :role)");
foreach ($users as $user) {
// Check if user already exists
$check = $pdo->prepare("SELECT id FROM users WHERE email = :email");
$check->execute(['email' => $user['email']]);
if ($check->rowCount() == 0) {
$stmt->execute($user);
}
}
echo "Users table created and seeded successfully." . PHP_EOL;
} catch (PDOException $e) {
die("DB ERROR: " . $e->getMessage());
}