| Server IP : 72.60.21.38 / Your IP : 216.73.216.25 Web Server : LiteSpeed System : Linux uk-fast-web1372.main-hosting.eu 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64 User : u390967363 ( 390967363) PHP Version : 8.2.30 Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/u390967363/domains/aibenproperties.com/public_html/crm/ |
Upload File : |
<?php
session_start();
require 'config.php';
include 'auth-guard.php';
require 'super-guard.php';
if (!isset($_GET['id']) || empty($_GET['id'])) {
echo "<script>alert('Admin ID not specified.'); window.location.href='admins.php';</script>";
exit();
}
$id = intval($_GET['id']);
// Fetch current admin data
$stmt = $conn->prepare("SELECT * FROM admins WHERE id = ?");
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
$admin = $result->fetch_assoc();
if (!$admin) {
echo "<script>alert('Admin not found.'); window.location.href='admins.php';</script>";
exit();
}
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = filter_var(trim($_POST['email']), FILTER_SANITIZE_EMAIL);
$password = trim($_POST['password']);
if (!empty($password)) {
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
$stmt = $conn->prepare("UPDATE admins SET email = ?, password = ? WHERE id = ?");
$stmt->bind_param("ssi", $email, $hashedPassword, $id);
} else {
$stmt = $conn->prepare("UPDATE admins SET email = ? WHERE id = ?");
$stmt->bind_param("si", $email, $id);
}
if ($stmt->execute()) {
echo "<script>alert('Admin updated successfully.'); window.location.href='admins.php';</script>";
exit();
} else {
echo "<script>alert('Update failed.');</script>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Edit Admin | Aiben CRM</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet" />
</head>
<body class="bg-gray-100 min-h-screen">
<main class="flex-1 p-4 md:p-8 overflow-y-auto max-w-screen-xl mx-auto w-full">
<div class="max-w-xl mx-auto mt-12 bg-white p-6 rounded-lg shadow-md">
<h2 class="text-2xl font-bold text-blue-800 mb-4">Edit Admin Account</h2>
<form method="POST" class="space-y-4">
<div>
<label class="block font-medium text-gray-700">Email</label>
<input type="email" name="email" value="<?php echo htmlspecialchars($admin['email']); ?>" class="w-full p-3 border rounded" required>
</div>
<div>
<label class="block font-medium text-gray-700">New Password (leave blank to keep current)</label>
<input type="password" name="password" class="w-full p-3 border rounded">
</div>
<div class="flex justify-between items-center">
<a href="admins.php" class="text-gray-600 hover:underline">← Cancel</a>
<button type="submit" class="bg-blue-700 text-white px-6 py-2 rounded hover:bg-blue-800">Update</button>
</div>
</form>
</div>
</main>
</body>
</html>