Файл: app/shop/del.php
Строк: 8
<?php
if (!$user->isAuth()) {
redirect('/');
exit;
}
$id = Clean::int($_GET['id']);
$shop = $db->prepare('SELECT * FROM `shop` WHERE `id` = ? and `user` = ?');
$shop -> execute([$id,$user->get()->user_id]);
$shop = $shop -> fetch(PDO :: FETCH_ASSOC);
if(!isset($shop['id'])){
header('Location: /');
exit;
}
$up = $db->prepare('UPDATE `users` SET `money` = `money` + ? WHERE `user_id` = ?');
$up -> execute([$shop['money'],$shop['user']]);
$del = $db->prepare('DELETE FROM `shop` WHERE `id` = ?');
$del -> execute([$shop['id']]);
Notif :: message('Площадка успешно удалена','/shop');
exit;