$msg = ""; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $username = $_POST['username']; $new_pass = $_POST['new_password']; $confirm_pass = $_POST['confirm_password']; // Check admin exists $stmt = $conn->prepare("SELECT id FROM admins WHERE username=? AND role='admin'"); $stmt->bind_param("s", $username); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows == 1) { if ($new_pass === $confirm_pass) { $new_hash = password_hash($new_pass, PASSWORD_BCRYPT); $stmt->bind_result($admin_id); $stmt->fetch(); $update = $conn->prepare("UPDATE admins SET password=? WHERE id=?"); $update->bind_param("si", $new_hash, $admin_id); if ($update->execute()) { $msg = "✅ Password reset successfully! Login Now"; } else { $msg = "❌ Failed to reset password."; } $update->close(); } else { $msg = "❌ Passwords do not match."; } } else { $msg = "❌ Username not found or not an admin."; } $stmt->close(); } ?> Forgot Admin Password

Forgot Password

⬅️ Back to Login