21 lines
447 B
PHP
21 lines
447 B
PHP
<?php
|
|
session_start();
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
// Check if user is logged in
|
|
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
if (!isset($_GET['id'])) {
|
|
die('Product ID not specified.');
|
|
}
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare('DELETE FROM products WHERE id = ?');
|
|
$stmt->execute([$_GET['id']]);
|
|
|
|
header('Location: products.php?status=deleted');
|
|
exit;
|
|
?>
|