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':
if (isset($_POST['wishlist'])) {
$wishlist = $database
->query('SELECT *
->query(
'SELECT *
FROM `wishlists_saved`
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . '
;')
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ';'
)
->fetch();
if ($wishlist) {
/** Delete */
$database
->query('DELETE FROM `wishlists_saved`
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . '
;');
->query(
'DELETE FROM `wishlists_saved`
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . ';'
);
$response['action'] = 'deleted';
} else {
/** Create */
$database
->query('INSERT INTO `wishlists_saved` (
->query(
'INSERT INTO `wishlists_saved` (
`user`,
`wishlist`
) VALUES (
' . $_SESSION['user']->id . ',
' . Sanitiser::getNumber($_POST['wishlist']) . '
)
;');
);'
);
$response['action'] = 'created';
}