<?php
session_start();
if (!isset($_SESSION['admin_id'])) {
header('Location: login.php');
exit;
}
include '../db.php';
$id = intval($_GET['id'] ?? 0);
// Only proceed if ID is valid (> 0)
if ($id > 0) {
// Optional: delete related reviews first to avoid orphan data
$pdo->prepare("DELETE FROM reviews WHERE company_id = ?")->execute([$id]);
// Delete the company itself
$pdo->prepare("DELETE FROM companies WHERE id = ?")->execute([$id]);
}
header('Location: edit_company.php');
exit;
?>