<?php 
session_start();
include('../dist/includes/dbcon.php');
	$branch=$_SESSION['branch'];
	$last = $_POST['last'];
	$first = $_POST['first'];
	$address = $_POST['address'];
	$contact = $_POST['contact'];
	$note = $_POST['note'];
	$muni = $_POST['muni'];
	$business = $_POST['business'];
	$messenger = $_POST['messenger'];
	
	$query2=mysqli_query($con,"select * from customer where cust_last='$last' and cust_first='$first' ")or die(mysqli_error($con));
		$count=mysqli_num_rows($query2);

		if ($count>0)
		{
			echo "<script type='text/javascript'>alert('Customer already exist!');</script>";
			echo "<script>document.location='cust_new1.php'</script>";  
		}
		else
		{	
			
			mysqli_query($con,"INSERT INTO customer(cust_last,cust_first,cust_address,cust_contact,branch_id,balance,cust_pic,credit_status,nickname,municipality,house_status,emp_address) 
				VALUES('$last','$first','$address','$contact','$branch','0','default.gif','Approved','$note','$muni','$business','$messenger')")or die(mysqli_error($con));

			$id=mysqli_insert_id($con);
			//$_SESSION['cid']=$id;
			//echo "<script type='text/javascript'>alert('Successfully added new customer!');</script>";
			echo "<script>document.location='cust_new1.php'</script>";  
		}
?>