<?php
include('../headertop.php');
include('../db.php');
//include('../datepicker.php');

$disp = '';
$pagetitle = 'Delete Employee Information';

if(!isset($_POST['deleteemployeesubmit']))
{
echo '<meta http-equiv="refresh" content="0;URL=viewemployees.php">';
exit;
}

$id = $_POST['id'];
$qdel = "select * from employee where id='$id'";
$rdel = mysqli_query($dbcon,$qdel);
$rwdel = mysqli_fetch_array($rdel);
$photopath = $rwdel['photopath'];

$q = "delete from employee where id='$id'";
$res = mysqli_query($dbcon,$q);

if(!$res)
{
$disp .= '<span class="error">Changes could not be deleted: '.mysqli_error($dbcon).'</span>';
include('../template.php');
exit;
}

$sm = "Employee Details Deleted ";


if(@unlink($photopath))
$sm .= 'and photo deleted';
else
$sm .= 'but photo could not be deleted';


echo '<meta http-equiv="refresh" content="0;URL=viewemployees.php?sm='.$sm.'">';
