<?php 
  require "connectionDb.php";

  if (isset($_POST['edit']) && isset($_POST['id']) && isset($_POST['username']) ) {
    
     $id = $_POST['id'];
     $username = $_POST['username'];
     $creditSale = $_POST['creditSale'];
     //$vehicle_id = $_POST['vehicle_id'];
     //$number = $_POST['number'];
     
    $sql ="UPDATE customer SET name='$username',credit_sale='$creditSale' WHERE id='$id'";
    //$sql2 ="UPDATE vehicle SET number='$number' WHERE id='$vehicle_id'";
    $db->exec($sql);
    //$db->exec($sql2);
    echo '<script>window.location.href="index.php"</script>';
  }
 

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

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

    <div class="form-group">
     <label class="control-label col-sm-2"> Credit Sale</label>
      <div class="col-sm-10"> 
      <!-- <input id="creditSaleOn" type="checkbox" name="creditSale">
      <input id="creditSaleOff" type="checkbox" name="creditSale"> -->
      <input id="creditSaleOn" type="radio" name="creditSale" value="1"> Yes<br>
      <input id="creditSaleOff" type="radio" name="creditSale" value="0"> No<br>
   </div>
  </div>

 <!--  <input type="number" name="vehicle_id" id="vehicle_id" hidden="hidden">

  <div class="form-group">
     <label class="control-label col-sm-2"> Number</label>
      <div class="col-sm-10"> 
      <input id="number" type="text" name="number">
   </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="edit">
        </div>
    </div>
    </form>
</div>