yogibook_aury_new/public/mark_lost.php
2025-09-01 15:06:58 +02:00

54 lines
1.5 KiB
PHP

<?php
// mark_lost.php
// Start output buffering to capture any unexpected output
ob_start();
// Set the content type to JSON
header('Content-Type: application/json');
// Include database connection (assuming headscript.php contains this)
require_once('include/headscript.php');
// Suppress errors to prevent them from being output
ini_set('display_errors', 0);
error_reporting(0);
// Connect to the database
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
// Clean the output buffer before sending the response
ob_end_clean();
echo json_encode(['success' => 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;