<?php
include("connection.php");
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

if (!isset($_GET['id'])) {
    header("Location: viewmeta_tag.php");
    exit;
}

$id = intval($_GET['id']);

// Check if record exists
$check = mysqli_query($con, "SELECT * FROM meta_tag WHERE id = $id");
if (mysqli_num_rows($check) == 0) {
    echo "Record not found!";
    exit;
}

// Delete record
$delete = mysqli_query($con, "DELETE FROM meta_tag WHERE id = $id");

if ($delete) {
    header("Location: viewmeta_tag.php");
    exit;
} else {
    echo "Failed to delete record: " . mysqli_error($con);
}
?>
