false, 'message' => 'Connessione al database fallita']); exit; } if (isset($_POST['id'])) { $id = intval($_POST['id']); $sql = "UPDATE bookingclass SET lostlesson = 'Y' WHERE idbookingclass = ?"; $stmt = mysqli_prepare($conn, $sql); mysqli_stmt_bind_param($stmt, 'i', $id); if (mysqli_stmt_execute($stmt)) { // Clean the output buffer before sending the response ob_end_clean(); echo json_encode(['success' => true]); } else { // Clean the output buffer before sending the response ob_end_clean(); echo json_encode(['success' => false, 'message' => 'Errore durante l\'aggiornamento: ' . mysqli_error($conn)]); } mysqli_stmt_close($stmt); } else { // Clean the output buffer before sending the response ob_end_clean(); echo json_encode(['success' => false, 'message' => 'ID non fornito']); } mysqli_close($conn); // Ensure no extra output is sent exit;