29 lines
834 B
PHP
29 lines
834 B
PHP
<?php
|
|
include('include/headscript.php');
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
$id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
|
|
$titolo = trim($_POST['titolo'] ?? '');
|
|
|
|
if ($id <= 0) {
|
|
echo json_encode(['success' => false, 'message' => 'ID non valido']);
|
|
exit;
|
|
}
|
|
if ($titolo === '') {
|
|
echo json_encode(['success' => false, 'message' => 'Il titolo non può essere vuoto']);
|
|
exit;
|
|
}
|
|
|
|
$titolo = mb_substr($titolo, 0, 255);
|
|
|
|
try {
|
|
$pdo = DBHandlerSelect::getInstance()->getConnection();
|
|
|
|
$stmt = $pdo->prepare("UPDATE mescole_files SET titolo = ? WHERE id = ?");
|
|
$stmt->execute([$titolo, $id]);
|
|
|
|
echo json_encode(['success' => true, 'titolo' => $titolo]);
|
|
} catch (Throwable $e) {
|
|
echo json_encode(['success' => false, 'message' => 'Errore database: ' . $e->getMessage()]);
|
|
}
|