Actualiser api.php
This commit is contained in:
@@ -143,22 +143,28 @@ switch ($action) {
|
|||||||
echo json_encode(["success" => true]);
|
echo json_encode(["success" => true]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete_film':
|
case 'delete_film':
|
||||||
checkAuth($pdo);
|
checkAuth($pdo);
|
||||||
$type = $_GET['type'] ?? 'critique';
|
$type = $_GET['type'] ?? 'critique';
|
||||||
$table = ($type === 'videotheque') ? 'videotheque' : 'critiques';
|
$table = ($type === 'videotheque') ? 'videotheque' : 'critiques';
|
||||||
$id = $_GET['id'] ?? null;
|
$id = $_GET['id'] ?? null;
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
echo json_encode(["error" => "ID manquant."]);
|
echo json_encode(["error" => "ID manquant."]);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stmt = $pdo->prepare("DELETE FROM $table WHERE id = ?");
|
|
||||||
$stmt->execute([$id]);
|
|
||||||
echo json_encode(["success" => true]);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM $table WHERE id = ?");
|
||||||
|
$stmt->execute([$id]);
|
||||||
|
|
||||||
|
if ($stmt->rowCount() === 0) {
|
||||||
|
http_response_code(404);
|
||||||
|
echo json_encode(["error" => "Aucun enregistrement trouvé avec cet ID."]);
|
||||||
|
} else {
|
||||||
|
echo json_encode(["success" => true]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'bulk_delete':
|
case 'bulk_delete':
|
||||||
checkAuth($pdo);
|
checkAuth($pdo);
|
||||||
|
|||||||
Reference in New Issue
Block a user