hasRight('kundenkarte', 'write')) { http_response_code(403); echo json_encode(array('error' => 'Permission denied')); exit; } header('Content-Type: application/json'); $id = GETPOSTINT('id'); $qty = GETPOSTFLOAT('qty'); if ($id <= 0) { echo json_encode(array('error' => 'Invalid ID')); exit; } if ($qty <= 0) { echo json_encode(array('error' => 'Invalid quantity')); exit; } $favoriteProduct = new FavoriteProduct($db); $result = $favoriteProduct->fetch($id); if ($result <= 0) { echo json_encode(array('error' => 'Record not found')); exit; } $favoriteProduct->qty = $qty; $result = $favoriteProduct->update($user); if ($result > 0) { echo json_encode(array( 'success' => true, 'id' => $id, 'qty' => $qty )); } else { echo json_encode(array('error' => $favoriteProduct->error)); }