<?php
include '../connect.php';
session_start();

$kadPengenalan =$_GET['kadPengenalan'];
$ic = $_SESSION["kadPengenalan"];

		$query="DELETE FROM user WHERE kad_pengenalan = '".$kadPengenalan."'";
		$strQuery = mysqli_query($conn,$query);
		
		if($strQuery) 
			{	
				date_default_timezone_set("Asia/Kuala_Lumpur");			
				$date=date('Y-m-d');
				$time=date('H:i:sa');
				
				$kadPengenalan= $_SESSION["kadPengenalan"];
				
				$q4="INSERT INTO audit_trail(kad_pengenalan,tarikh,masa,operasi,catatan)
						VALUES ('$ic','$date','$time','Hapus','Hapus pengguna ID $kadPengenalan')";
				$strQuery1 = mysqli_query($conn,$q4);
				
				if($strQuery1)
				{
					echo "<script>alert('Maklumat pengguna berjaya dipadam.');";
					echo "window.location.href = '../approvePage.php';</script>";		
					exit;
				}
				else
				{
					echo 'MySQL Error: ' . mysqli_error($conn);
					exit;
				}
			}
			else
			{
				echo 'MySQL Error: ' . mysqli_error($conn);
				exit;
			}
?>