<?php 
include "config.php";

$code = $_POST['code'];
$name = $_POST['customername'];
$mobile = $_POST['mobile'];
$purchaseopening = $_POST['purchaseopening'];
$credit=$_POST['credit'];
$saleopening = $_POST['salesopening'];
$pincode=$_POST['pincode'];
$address = $_POST['address'];
$state=$_POST['state'];
$gst = $_POST['gst'];
$district = $_POST['district'];
$blockdate=empty($_POST['blockdate'])?'-':$_POST['blockdate'];
$single_entry = $_POST['forsingleentry'];
$code_validate = mysqli_query($connect,"select count(code) as code from customerdetails where code='$code' && status!='deleted'");
$code_count=mysqli_fetch_assoc($code_validate);
$code_val = $code_count['code'];
if($code_val==0)
{
$sql = "insert into customerdetails (code,name,mobile,creditlimit,purchaseopening,salesopening,pincode,gst,address,district,state,blockdate,date,time,single_entry,editdate,edittime,editby,status) values('$code','$name','$mobile','$credit','$purchaseopening','$saleopening','$pincode','$gst','$address','$district','$state','$blockdate',CURRENT_DATE(),CURRENT_TIME(),'$single_entry','','','','')";
echo $sql;
 $go = mysqli_query($connect,$sql);
}
  header('Location:mastercustomer.php');

?>