This commit is contained in:
grandeljay 2022-11-11 13:41:01 +01:00
parent aa1c391166
commit dcb0f74aa9
2 changed files with 19 additions and 16 deletions

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';
} }

View file

@ -1,7 +1,7 @@
<?php <?php
/** /**
* home.php * Blog
* *
* @author Jay Trees <github.jay@grandel.anonaddy.me> * @author Jay Trees <github.jay@grandel.anonaddy.me>
*/ */