<?php
session_start();

include "../functions.php";

include "../conn.php";

checkAdmin(session_id());

$productid = $_POST["productid"];
$catid = $_POST["catid"];
	
delpro($productid);
	
header ("location: products.php?catid=$catid");

function delpro($productid)
{
	
	$res = mysql_query("select productpic from products where productid='$productid'");
	while ($row = mysql_fetch_array($res))
	{
		$productpic = $row[0];
		@unlink($productpic);
	}
	mysql_query("delete from products where productid='$productid'");
}
?>