<?php 
include "config.php";
session_start();
$user=$_SESSION['log'];
$code = $_POST['code'];
$date = $_POST['date'];
$time = $_POST['time'];
$givento = $_POST['givento'];
$givenby = $_POST['givenby'];
$given_amount=$_POST['given_amount'];
$remark = $_POST['remark'];
$financial_year = $_POST['financialyear'];
$update = mysqli_query($connect,"update cash_handling set status='deleted',editdate=CURRENT_DATE(),edittime=CURRENT_TIME() where code ='$code'");
$code_validate = mysqli_query($connect,"select count(code) as code from cash_handling where code='$code' && status!='deleted'");
$code_count=mysqli_fetch_assoc($code_validate);
$code_val = $code_count['code'];
if($code_val==0)
{
$sql = "INSERT INTO cash_handling(date, givento, givenby, given_amount, remark,  code, user, time,financialyear, editdate, edittime, status) VALUES ('$date','$givento','$givenby','$given_amount','$remark','$code','$user',CURRENT_TIME(),'$accountyear','','','')";
echo $sql;
 $go = mysqli_query($connect,$sql);
}
 header('Location:cash_handling.php');

?>