<?php
session_start();
include "../functions.php";

$sessionID = session_id();

checkAdmin($sessionID);

if ($_POST["confirm"] == 1)
{
	$categoryID = $_POST["categoryID"];
	
	$query = "update news set categoryID=0 where categoryID='$categoryID'";
	mysql_query ($query) or die (mysql_error());
	$query = "delete from news_category where categoryID='$categoryID'";
	mysql_query ($query) or die (mysql_error());
	
	header("location: category.php");
}

?>

<?php
$title = "Delete Category";
include "header.php";
$categoryID = $_POST["categoryID"];
$query = "select categoryName from news_category where categoryID='$categoryID'";
$result = mysql_query($query) or die (mysql_error());

while ($row = mysql_fetch_array($result))
{
	$categoryName = $row[0];
}

?>

<tr>
<td align="center">
Are you sure you want to delete the category:<b><?php echo $categoryName; ?></b>?
</td>
</tr>

<tr>
<td align="center">
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="hidden" name="categoryID" value="<?php echo $categoryID; ?>">
<input type="hidden" name="confirm" value="1">
<input type="submit" value="Yes">
</td></form>
</tr>

<tr>
<td align="center">
<form action="category.php" method="get">
<input type="submit" value=" No ">
</td></form>
</tr>

<?php
include "footer.php";
?>