<?php
include "header.php";

if ($_POST["confirm"] == 1)
{
	$eventid = $_POST["id"];
	
	$query = "select imgpath from events where eventid='$eventid'";
	$result = mysql_query($query) or die (mysql_error());
	while ($row = mysql_fetch_array($result))
	{
		@unlink($row[0]);
	}
	
	$query = "select bropath from events where eventid='$eventid'";
	$result = mysql_query($query) or die (mysql_error());
	while ($row = mysql_fetch_array($result))
	{
		@unlink($row[0]);
	}
	
	mysql_query("delete from events where eventid='$eventid'") or die (mysql_error());
		
	echo "<script>window.location='index.php'</script>";
}

$eventid = $_POST["id"];


$query = "select title from events where eventid='$eventid'";
$result = mysql_query($query) or die (mysql_error());
if ($row = mysql_fetch_array($result))
{
	$title = $row[0];
}
?>

<center>
<table cellspacing="0" cellpadding="5" border="0">
  <tr>
    <td align="center">Are you sure you want to delete the event: <b><?php echo $title; ?></b>?</td>
  </tr>
  
  <tr>
    <td align="center"><form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"><input type="hidden" name="id" value="<?php echo $eventid; ?>"><input type="hidden" name="confirm" value="1"><input type="submit" value="Yes"></td></form>
  </tr>
  
  <tr>
    <td align="center"><form action="index.php" method="post"><input type="submit" value=" No "></td></form>
  </tr>
</table>
</center>

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