-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed_admin.php
More file actions
41 lines (36 loc) · 1.45 KB
/
Copy pathseed_admin.php
File metadata and controls
41 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
// seed_admin.php
// One‐off script to bulk‐insert admin accounts.
// Run this once, then remove or secure it.
include 'db_connection.php'; // $conn = new mysqli(...)
// Define your six proponents here:
$admins = [
['username' => 'James Aries', 'email' => 'aries@codegame.dev', 'password' => 'Areys27'],
['username' => 'Bob', 'email' => 'bob@codegame.dev', 'password' => 'BobPass123'],
['username' => 'Carol', 'email' => 'carol@codegame.dev', 'password' => 'CarolPass123'],
['username' => 'Dave', 'email' => 'dave@codegame.dev', 'password' => 'DavePass123'],
['username' => 'Eve', 'email' => 'eve@codegame.dev', 'password' => 'EvePass123'],
['username' => 'Frank', 'email' => 'frank@codegame.dev', 'password' => 'FrankPass123'],
];
$stmt = $conn->prepare("
INSERT INTO admin_users (username, email, password_hash, role, created_at)
VALUES (?, ?, ?, 'super_admin', NOW())
");
if ( ! $stmt ) {
die("Prepare failed: " . $conn->error);
}
foreach ($admins as $admin) {
$hash = password_hash($admin['password'], PASSWORD_DEFAULT);
$stmt->bind_param("sss",
$admin['username'],
$admin['email'],
$hash
);
if ($stmt->execute()) {
echo "Created admin: {$admin['username']} ({$admin['email']})<br>";
} else {
echo "Error creating {$admin['username']}: " . $stmt->error . "<br>";
}
}
$stmt->close();
$conn->close();