Mini Shell
<?php
session_start();
$rootPath = realpath(dirname(__FILE__) . '/..');
require_once $rootPath . '/Portal/config/config.php';
require_once $rootPath . '/Portal/include/auth_validate.php';
$del_id = filter_input(INPUT_POST, 'del_id');
$db = getDbInstance();
if($_SESSION['User_Type']=='Student'){
header('HTTP/1.1 401 Unauthorized', true, 401);
exit("401 Unauthorized");
}
// Delete a user using user_id
if ($del_id && $_SERVER['REQUEST_METHOD'] == 'POST') {
$db->where('id', $del_id);
$stat = $db->delete('admin_accounts');
if ($stat) {
//Event Trail
date_default_timezone_set('Africa/Blantyre');
$EventTime = date('d-m-Y H:i', time());
$Action = $RecordType = $Details = $Date = $User = '';
$Action = 'Delete Record';
$RecordType = 'User Account';
$Details = "with User ID Number $del_id";
$Date = "$EventTime";
$User = $_SESSION['Full_Name'];
$sql = mysqli_query($conn,"INSERT INTO eventtrail (Action,RecordType,Details,Date,User)
VALUES ('$Action','$RecordType','$Details','$Date','$User')");
$_SESSION['info'] = "User deleted successfully!";
}
}