<?php 
  require "connectionDb.php";
    if (isset($_POST['addCustomer']) && isset($_POST['addusername']) ) {
   
     // echo $id = $_GET['id'];
     $username = $_POST['addusername'];
     echo $creditSale = ($_POST['addcreditSale']=='on') ? 1 : 0 ;
     // echo $vehicle_id = $_GET['vehicle_id'];
     // echo $number = $_GET['number'];
     
    // $sql1 ="INSERT INTO customer (type,created_at,updated_at,name,credit_sale) VALUES ('',datetime('now', 'localtime'),datetime('now', 'localtime'),'$username','$creditSale'";
     // $sql2 ="INSERT INTO vehicle (type,created_at,updated_at,customer_id,number) VALUES ('$vehicle_id','',MOW(),datetime('now', 'localtime'),'$id','$number')";
    $db->exec("INSERT INTO customer (type,created_at,updated_at,name,credit_sale) VALUES ('',datetime('now', 'localtime'),datetime('now', 'localtime'),'$username','$creditSale');");
    // $db->exec($sql2);
    echo '<script>window.location.href="index.php"</script>';
    }


 ?>
 <style type="text/css">
   .addForm {
    display: none;
   }
 </style>
<div class="container addForm" id="addForm">
    <form class="form-horizontal" action="" method="post">

    <div class="form-group">
     <label class="control-label col-sm-2"> Name </label>
    <div class="col-sm-10"> 
      <input type="text" name="addusername">
    </div>
   </div>

    <div class="form-group">
     <label class="control-label col-sm-2"> Credit Sale</label>
      <div class="col-sm-10"> 
      <input type="checkbox" name="addcreditSale">
   </div>
  </div>

  <div class="form-group">        
      <div class="col-sm-offset-2 col-sm-10">
        <input type="submit" class="btn btn-default" value="Submit" name="addCustomer">
        </div>
    </div>
    </form>
</div>