<?php
session_start();
$iduser=$_SESSION['user_idd'];

include('../include/config.php');
$date = new DateTime("now", new DateTimeZone('Africa/Nairobi') );
$timenow=$date->format('Y-m-d H:i:s');
$timenow2=$date->format('Y-m-d');
$month=$date->format('M');


if(isset($_POST['id']))
{
$id =addslashes($_POST['id']);
$sql=mysqli_query($con,"DELETE from projects where id='$id'");
if($sql)
{
$msg='deleted one of the project';
 $sql2=mysqli_query($con,"INSERT INTO activity(user,Action,Tim,Dat,shortmsg,Month) VALUES('$iduser','$msg','$timenow','$timenow2','delete','$month') ");
 if($sql2)
 {
    echo 'success'; 
 }
}else
{
    echo 'Sorry. Error occured while deleting data';
}

} else if(isset($_POST['idd']))
{
 $id =addslashes($_POST['idd']);
$sql=mysqli_query($con,"DELETE from prodata where id='$id'");
if($sql)
{
$msg='deleted a projected record';
 $sql2=mysqli_query($con,"INSERT INTO activity(user,Action,Tim,Dat,shortmsg,Month) VALUES('$iduser','$msg','$timenow','$timenow2','delete','$month') ");
 if($sql2)
 {
    echo 'success'; 
 }
}else
{
    echo 'Sorry. Error occured while deleting data';
}   
    
}

?>