Refactor
This commit is contained in:
parent
aa1c391166
commit
dcb0f74aa9
2 changed files with 19 additions and 16 deletions
|
@ -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(
|
||||||
|
'SELECT *
|
||||||
FROM `wishlists_saved`
|
FROM `wishlists_saved`
|
||||||
WHERE `wishlist` = ' . Sanitiser::getNumber($_POST['wishlist']) . '
|
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(
|
||||||
|
'INSERT INTO `wishlists_saved` (
|
||||||
`user`,
|
`user`,
|
||||||
`wishlist`
|
`wishlist`
|
||||||
) VALUES (
|
) VALUES (
|
||||||
' . $_SESSION['user']->id . ',
|
' . $_SESSION['user']->id . ',
|
||||||
' . Sanitiser::getNumber($_POST['wishlist']) . '
|
' . Sanitiser::getNumber($_POST['wishlist']) . '
|
||||||
)
|
);'
|
||||||
;');
|
);
|
||||||
|
|
||||||
$response['action'] = 'created';
|
$response['action'] = 'created';
|
||||||
}
|
}
|
||||||
|
|
|
@ -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>
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue