This commit is contained in:
grandeljay 2022-11-10 11:09:06 +01:00
parent c5c2893201
commit 832765e4a6

View file

@ -26,31 +26,34 @@ switch ($_SERVER['REQUEST_METHOD']) {
case 'POST': case 'POST':
if (isset($_POST['wishlist'])) { if (isset($_POST['wishlist'])) {
$wishlist = $database $wishlist = $database
->query('SELECT * ->query(
FROM `wishlists_saved` 'SELECT *
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ' FROM `wishlists_saved`
;') WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ';'
)
->fetch(); ->fetch();
if ($wishlist) { if ($wishlist) {
/** Delete */ /** Delete */
$database $database
->query('DELETE FROM `wishlists_saved` ->query(
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ' 'DELETE FROM `wishlists_saved`
;'); WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ';'
);
$response['action'] = 'deleted'; $response['action'] = 'deleted';
} else { } else {
/** Create */ /** Create */
$database $database
->query('INSERT INTO `wishlists_saved` ( ->query(
`user`, 'INSERT INTO `wishlists_saved` (
`wishlist` `user`,
) VALUES ( `wishlist`
' . $_SESSION['user']->id . ', ) VALUES (
' . Sanitiser::getNumber($_POST['wishlist']) . ' ' . $_SESSION['user']->id . ',
) ' . Sanitiser::getNumber($_POST['wishlist']) . '
;'); );'
);
$response['action'] = 'created'; $response['action'] = 'created';
} }