Mini Shell
<?php
session_start();
require_once 'config/config.php';
require_once 'include/auth_validate.php';
/////// Code for new access control on header menu /////////////////////////
$User = $_SESSION['id'];
$Counter = "";
date_default_timezone_set('Africa/Blantyre');
$VisitTime = date('YmdHis', time());
$results = mysqli_query( $connection,"SELECT * FROM admin_accounts WHERE id = '$User' ");
$nums = mysqli_num_rows($results);
if ($nums >0){
$rows = mysqli_fetch_array($results);
$UserAccessName = $rows['UserAccessName'];
$StudentName = $rows['Full_Name'];
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$DebtorType = $_POST['DebtorType'];
$name=$_FILES['file']['name'];
$size=$_FILES['file']['size'];
$type=$_FILES['file']['type'];
$temp=$_FILES['file']['tmp_name'];
$fname = $VisitTime.'_'.$name;
$move = move_uploaded_file($temp,"Uploads/".$fname);
$CSVvar = fopen("Uploads/$fname", "r");
if ($CSVvar !== FALSE) {
$_SESSION['success'] = "Records below have been Uploaded Successfully!";
include_once 'include/AdminHeader.php';
?>
<html>
<div id="page-wrapper">
<div class="row">
<br><br><br><hr>
</div>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr><td colspan ="8"><?php include('include/flash_messages.php') ?></td></tr>
<tr style= "background-color:#BAC4CC;">
<th>Number</th>
<th>Debtor Number</th>
<th>Debtor Name </th>
<th>Property Number</th>
<th>Address</th>
<th>Phone</th>
<th>Status</th>
<th>Balance</th>
</tr>
</thead>
<?php
while (! feof($CSVvar)) {
$data = fgetcsv($CSVvar, 1000, ",");
if (! empty($data)) {
$DebtorNumber = $data[0];
$DebtorName = $data[1];
$PropertyNumber = $data[2];
$Address = $data[3];
$Phone = $data[4];
$Status = $data[5];
$Balance = $data[6];
$sql = mysqli_query($connection,"DELETE FROM debtorslist WHERE DebtorNo = '$DebtorNumber'");
$sql = mysqli_query($connection,"INSERT INTO debtorslist (DebtorNo,Name,PropertyNo,DebtorType,Address,Phone,Status,Balance)
values('$DebtorNumber','$DebtorName','$PropertyNumber','$DebtorType','$Address','$Phone','$Status','$Balance')");
$sql = mysqli_query($connection,"DELETE FROM receipts WHERE DEBTORID = '$DebtorNumber'");
$Counter = $Counter + 1;
?>
<tr>
<td><h5><?php echo $Counter; ?></h5></td>
<td><h5><?php echo $DebtorNumber;?></h5></td>
<td><h5><?php echo $DebtorName; ?></h5></td>
<td><h5><?php echo $PropertyNumber; ?></h5></td>
<td><h5><?php echo $Address; ?></h5></td>
<td><h5><?php echo $Phone; ?></h5></td>
<td><h5><?php echo $Status; ?></h5></td>
<td><h5><?php echo $Balance; ?></h5></td>
</tr>
<?php
}?>
<?php
} ?>
<tr><td><h5><?php echo $Counter; ?></h5></td><td colspan ="7" align = "center"><strong>THERE ARE <?php echo $Counter; ?> RECORDS IN TOTAL<strong></td></tr>
</table>
</html>
<?php
}
fclose($CSVvar);
}
?>
</div>