<?php
// include db connect class
require_once __DIR__ . '/../DBConnect.php';
if (isset($_POST['ClientID']) && isset($_POST['AcNameID'])&& isset($_POST['ClientUserID']) && isset($_POST['UserRights'])) {
    $AcNameID = $_POST['AcNameID'];
    $ClientID = $_POST['ClientID'];
    $ClientUserID = $_POST['ClientUserID'];
    $UserRights = $_POST['UserRights'];

    $current_date = date("Y-m-d H:i:s");

    $sql = "UPDATE Account3Name SET UpdatedDate = '$current_date', UserRights = '$UserRights',
     ClientUserID = '$ClientUserID' WHERE ClientID = '$ClientID' && AcNameID = '$AcNameID'";

    try {
        $stmt = $conn->prepare($sql);
        $stmt->execute();
        $result = $stmt->rowCount();
    } catch (PDOException $e) {
        echo $sql . "<br>" . $e->getMessage();
    }
    // $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
    if ($result != 0) {
        // success
        $response["success"] = 1;
        $response["message"] = "Data Updated";
        // echoing JSON response
        echo json_encode($response);
    } else {
        // success
        $response["success"] = 0;
        $response["message"] = "No Client Availaible";
        // echoing JSON response
        echo json_encode($response);
    }
} else {
    // success
    $response["success"] = 0;
    $response["message"] = "Set All Parameter";
    // echoing JSON response
    echo json_encode($response);
}