-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset-admin.php
More file actions
78 lines (71 loc) · 2.54 KB
/
Copy pathreset-admin.php
File metadata and controls
78 lines (71 loc) · 2.54 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* Admin Credentials Reset Script
* Use this to reset the admin password if login fails
*/
require_once 'config/database.php';
// New admin credentials
$admin_email = 'admin@fptb.edu.ng';
$admin_password = 'admin123'; // Change this to your desired password
// Generate bcrypt hash
$password_hash = password_hash($admin_password, PASSWORD_BCRYPT);
try {
// Update user password
$stmt = $pdo->prepare("UPDATE users SET password_hash = ? WHERE email = ? AND role = 'admin'");
$stmt->execute([$password_hash, $admin_email]);
$affectedRows = $stmt->rowCount();
if ($affectedRows > 0) {
echo "<div style='padding: 20px; background: #d4edda; border: 1px solid #c3e6cb; border-radius: 5px; color: #155724;'>";
echo "<h2>✓ Admin Credentials Reset Successfully!</h2>";
echo "<p><strong>Email:</strong> {$admin_email}</p>";
echo "<p><strong>Password:</strong> {$admin_password}</p>";
echo "<p><strong>Password Hash:</strong> {$password_hash}</p>";
echo "<p><a href='login.php' style='text-decoration: none; color: #004085;'>→ Go to Login</a></p>";
echo "</div>";
} else {
echo "<div style='padding: 20px; background: #f8d7da; border: 1px solid #f5c6cb; border-radius: 5px; color: #721c24;'>";
echo "<h2>✗ Failed to Update Admin Account</h2>";
echo "<p>Admin user not found. Please run the installation script first.</p>";
echo "</div>";
}
} catch (Exception $e) {
echo "<div style='padding: 20px; background: #f8d7da; border: 1px solid #f5c6cb; border-radius: 5px; color: #721c24;'>";
echo "<h2>✗ Error</h2>";
echo "<p>" . $e->getMessage() . "</p>";
echo "</div>";
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Reset</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 40px 20px;
background: #f5f5f5;
}
.container {
max-width: 500px;
margin: 0 auto;
}
a {
display: inline-block;
margin-top: 15px;
padding: 10px 20px;
background: #007bff;
color: white;
text-decoration: none;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container">
<!-- Success/Error message is displayed above -->
<p style='margin-top: 20px;'><a href='index.php'>← Back to Home</a></p>
</div>
</body>
</html>