35512-vm/delete-asset.php
Flatlogic Bot 53eb27812c v1.1
2025-11-05 22:08:13 +00:00

29 lines
630 B
PHP

<?php
require_once 'auth-check.php';
if (!in_array($_SESSION['user_role'], ['Admin', 'Asset Manager', 'IT Technician'])) {
header("Location: index.php?error=access_denied");
exit;
}
require_once 'db/config.php';
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
header("Location: index.php");
exit;
}
$asset_id = $_GET['id'];
try {
$pdo = db();
$stmt = $pdo->prepare("DELETE FROM assets WHERE id = ?");
$stmt->execute([$asset_id]);
header("Location: index.php?success=asset_deleted");
exit;
} catch (PDOException $e) {
header("Location: index.php?error=db_error");
exit;
}
?>