Exemplo n.º 1
0
        $response['message'] = 'Invalid email address';
        echo json_encode($response);
        return;
    }
    if (!empty($password) && strlen($password) < 4) {
        $response['status'] = '403';
        $response['message'] = 'Password should be at least 4 characters.';
        echo json_encode($response);
        return;
    }
    if (empty($password)) {
        if (dbClass::editUser($id, $username, $email)) {
            $response['status'] = '200';
            $response['message'] = 'User has been successfully ' . $username . '.';
        } else {
            $response['status'] = '500';
            $response['message'] = 'Could not edit the user.';
        }
    } else {
        $password = $security->hashPwd($password);
        if (dbClass::editUserWithPwd($id, $username, $email, $password)) {
            $response['status'] = '200';
            $response['message'] = 'User has been successfully ' . $username . '.';
        } else {
            $response['status'] = '500';
            $response['message'] = 'Could not edit the user.';
        }
    }
    echo json_encode($response);
    return;
}