<?php
	session_start();
if (!isset($_SESSION['username'])) {
  header("location:login/main_login.php");
}

    // load up your config file
   include_once("setting.php");
   
    require_once(config);
    require_once(header);
?>
<div class="container">
<div class="row justify-content-md-center">
<?php include_once(menu_penal);
?>
</div>
<div class="row justify-content-md-center">
    <div class="col-5">
  <h2>Add New Customer Detail</h2> </div></div>
<?php     require_once(custom_form);
echo "</div>";
if(isset($_POST['submit'])){
$name= $_POST['cname'];
$fname = $_POST['cfname'];
$address = $_POST['address'];
$email = $_POST['email'];
$cnic = $_POST['cnic'];
$pkg = $_POST['pkg'];
$date = $_POST['date'];
$phone1= $_POST['phone1'];
$phone2 = $_POST['phone2'];
$status = $_POST['status'];
$other = "";
$datee=date('Y/m/d');
$sql = "INSERT INTO customer(c_name,c_fname,c_address,c_cnic,c_email,conn_date,c_pkg,c_phone1,c_phone2,c_other)
VALUES ('$name','$fname','$address','$cnic','$email','$date','$pkg','$phone1','$phone2','$other')";


if ($con->query($sql) === TRUE) {
$last_id = $con->insert_id;
echo $last_id;	
$sq = "INSERT INTO status(c_id,c_name,s_date,e_date,status,pkg_id) VALUES ('$last_id','$name','$date','$datee','$status','$pkg')";

   if ($con->query($sq) === TRUE) {
	echo '<script type="text/javascript">alert("New record:::' . $name .'_ID_'.$last_id. ':::created successfully"); </script>';   }else {
    echo "Error: " . $sq . "<br>" . $con->error;
}


    

} else {
    echo "Error: " . $sql . "<br>" . $con->error;
}

$con->close();
}
?>
<?php     require_once(footer);?>