Размер файла: 1.2Kb
<?php require_once('header.php'); ?>
<?php
// Предотвращение прямого доступа к этой странице.
if(!isset($_REQUEST['id'])) {
header('location: logout.php');
exit;
} else {
// Убедитесь, что идентификатор действителен или нет
$statement = $pdo->prepare("SELECT * FROM nrd_category WHERE category_id=?");
$statement->execute(array($_REQUEST['id']));
$total = $statement->rowCount();
if( $total == 0 ) {
header('location: logout.php');
exit;
}
}
?>
<?php
// Getting photo ID to unlink from folder
$statement = $pdo->prepare("SELECT * FROM nrd_news WHERE category_id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
unlink('../assets/uploads/'.$row['photo']);
}
// Delete from nrd_news
$statement = $pdo->prepare("DELETE FROM nrd_news WHERE category_id=?");
$statement->execute(array($_REQUEST['id']));
// Delete from nrd_category
$statement = $pdo->prepare("DELETE FROM nrd_category WHERE category_id=?");
$statement->execute(array($_REQUEST['id']));
header('location: category.php');
?>