<?php

require 'db2.php';

if (isset($_POST['submitAT'])) {
    $description = $_POST['description'];
    $filename = $_POST['file'];
    $dcount=count($description);
    for($i=0;$i<$dcount;$i++){
        echo ${'det'.$i}=$description[$i];
    }
    $time=date("H:s:i");
            $stmt = $conn->prepare("INSERT INTO my_updates (filename,type,Source, Subject, date_stamp, details, time ) 
            VALUES (?, ?, ?, ?, ?, ?, ?)");
            $stmt->bind_param("sssssss", $filename, $det0,$det1,$det2,$det4,$det5,$time);
            $stmt->execute();
            echo "The file ". htmlspecialchars(basename($_FILES["file"]["name"])). " has been uploaded.";
            $stmt->close();


$conn->close();
}

if (isset($_POST["insertclient"])) {
    $list = $_POST["list"];
    echo $dcount=count($list);
    for($i=0;$i<$dcount;$i++){
        echo ${"det".$i}=$list[$i];
    }

            $time=date("H:s:i");
            $stmt = $conn->prepare("INSERT INTO ft_enquiry (ft_Enquirycol, ft_Enquirycol1, ft_Enquirycol2, ft_Enquirycol3, ft_Enquirycol4, ft_Enquirycol5, ft_Enquirycol6, ft_Enquirycol7, ft_Enquirycol8, ft_Enquirycol9, ft_Enquirycol10, ft_Enquirycol11, ft_Enquirycol12, ft_Enquirycol13, ft_Enquirycol14, ft_Enquirycol15, ft_Enquirycol16, ft_Enquirycol17, ft_Enquirycol18, ft_Enquirycol19, ft_Enquirycol20, ft_Enquirycol21, ft_Enquirycol22, ft_Enquirycol23) 
            VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            $stmt->bind_param("ssssssssssssssssssssssss", $det0,$det1,$det2,$det3,$det4,$det5,$det6,$det7,$det8,$det9,$det10,$det11,$det12,$det13,$det14,$det15,$det16,$det17,$det18,$det19,$det20,$det21,$det22,$det23);
            $stmt->execute();
           // echo "The file ". htmlspecialchars(basename($_FILES["file"]["name"])). " has been uploaded.";
            $stmt->close();


$conn->close();
}

if (isset($_POST["delete"])) {
    $det0 = $_POST["id"];
            $time=date("H:s:i");
            $stmt = $conn->prepare("Delete from my_updates where id=?");
            $stmt->bind_param("s", $det0);
            $stmt->execute();
            $stmt->close();


$conn->close();
}

if (isset($_POST["deletec"])) {
    $det0 = $_POST["id"];
            $time=date("H:s:i");
            $stmt = $conn->prepare("Delete from ft_enquiry where id=?");
            $stmt->bind_param("s", $det0);
            $stmt->execute();
            $stmt->close();


$conn->close();
}
?>
