public function deleteTourImage() { if (!$this->loggedIn()) { header('Location: index.php?c=login&m=login'); } if (!isset($_GET['id'])) { header('Location: index.php?c=tour&m=index'); } $imageCollection = new ToursImagesCollection(); $image = $imageCollection->getOne($_GET['id']); if (is_null($image)) { header('Location: index.php?c=tour&m=index'); } $tourId = $image->getToursId(); unlink('uploads/tours/' . $image->getImage()); $imageCollection->delete($_GET['id']); header("Location: index.php?c=tour&m=tourImages&id=" . $tourId); }
<?php require_once 'common/header.php'; if (!loggedIn()) { header('Location: login.php'); } if (!isset($_GET['id'])) { header('Location: users.php'); } $imageCollection = new ToursImagesCollection(); $image = $imageCollection->getOne($_GET['id']); if (is_null($image)) { header('Location: tours.php'); } $tourId = $image->getToursId(); unlink('uploads/tours/' . $image->getImage()); $imageCollection->delete($_GET['id']); header("Location: tourImages.php?id=" . $tourId);