prepare("SELECT * FROM brand_details"); $stmt_brand->execute(); $result_brand = $stmt_brand->get_result(); if ($result_brand->num_rows > 0) { $brand = $result_brand->fetch_assoc(); $domainName = $brand['domain_name']; $webUrl = $brand['web_url']; $aboutDesc = $brand['about_desc']; $lightLogo = $brand['light_logo']; $darkLogo = $brand['dark_logo']; $ogImage = $brand['og_image']; $favicon = $brand['favicon']; $themeColor = $brand['theme_color']; $secondaryColor = $brand['secondary_color']; } $stmt_brand->close(); //For sending email use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require '../PHPMailer/src/Exception.php'; require '../PHPMailer/src/PHPMailer.php'; require '../PHPMailer/src/SMTP.php'; if (!isset($_SESSION["email"])) { header("Location: signin"); exit; } // Verify admin access $stmt_admin = $connect->prepare("SELECT role FROM admindb WHERE email = ?"); $stmt_admin->bind_param("s", $_SESSION['email']); $stmt_admin->execute(); $result_admin = $stmt_admin->get_result(); $admin = $result_admin->fetch_assoc(); $stmt_admin->close(); if (!$admin || $admin["role"] !== 'admin') { $msg['errorMsg'] = "Unauthorized access!"; header('Content-Type: application/json'); echo json_encode($msg); exit; } $msg = []; if (isset($_POST['userId']) && isset($_POST['value'])) { $userId = $_POST['userId']; $value = $_POST['value']; // Validate status value if ($value !== '0' && $value !== '1') { $msg['errorMsg'] = "Invalid status value!"; header('Content-Type: application/json'); echo json_encode($msg); exit; } $updateToken = bin2hex(random_bytes(10)); // Update status in users table $stmt = $connect->prepare("UPDATE users SET status = ?, token = ? WHERE id = ?"); $stmt->bind_param("ssi", $value, $updateToken, $userId); if ($stmt->execute()) { $msg['successMsg'] = $value == '1' ? "User verified successfully!" : "User access suspended!"; $msg['value'] = $value; $msg['userId'] = $userId; // Query to check if the email exists in the database $stmt_user = $connect->prepare("SELECT user_name, email FROM users WHERE id = ?"); $stmt_user->bind_param("i", $userId); $stmt_user->execute(); $result = $stmt_user->get_result(); $user = $result->fetch_assoc(); $stmt_user->close(); $username = $user['user_name']; $email = $user['email']; $capitalizedString = ucwords($username); // Create a new PHPMailer instance $mail = new PHPMailer(true); try { // Server settings $mail->isSMTP(); $mail->Host = $emailServer; $mail->SMTPAuth = true; $mail->Username = $emailUserName; $mail->Password = $emailPassword; $mail->SMTPSecure = $encryptionType; $mail->Port = $smtpPort; // Recipients $mail->setFrom($senderEmail, $senderName); $mail->addAddress($email, $username); // Content $mail->isHTML(true); // Your HTML email template content $message = '
'; if($value == "1") { $message .= '
|
|