<?php

$name=$_POST['name'];
$invoice_no=$_POST['invoice_no'];
$msisdn=$_POST['msisdn'];
$invoice_date=$_POST['invoice_date'];
$amount=$_POST['amount'];
$credit_date=$_POST['credit_date'];
$person_name=$_POST['person_name'];
require_once "config.php";

$sql="select * from invoice_details where  invoice_no='".$invoice_no."' and customer_name='".$name."' and status='pending'";
$query=mysqli_query($con,$sql);
if($result=mysqli_fetch_array($query)){
    die("Customer and Invoice exists");
}


$sql="insert into invoice_details(person_name,customer_name,invoice_no,msisdn,invoice_date,amount,balance,credit_date) values('".$person_name."','".$name."','".$invoice_no."','".$msisdn."','".$invoice_date."','".$amount."','".$amount."','".$credit_date."')";
$query=mysqli_query($con,$sql);
$count=mysqli_affected_rows($con);


if($query==false){
    die(mysqli_error($con));
}
echo $count;


?>