addCustomer.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. require "connectionDb.php";
  3. if (isset($_POST['addCustomer']) && isset($_POST['addusername']) ) {
  4. // echo $id = $_GET['id'];
  5. $username = $_POST['addusername'];
  6. echo $creditSale = ($_POST['addcreditSale']=='on') ? 1 : 0 ;
  7. // echo $vehicle_id = $_GET['vehicle_id'];
  8. // echo $number = $_GET['number'];
  9. // $sql1 ="INSERT INTO customer (type,created_at,updated_at,name,credit_sale) VALUES ('',datetime('now', 'localtime'),datetime('now', 'localtime'),'$username','$creditSale'";
  10. // $sql2 ="INSERT INTO vehicle (type,created_at,updated_at,customer_id,number) VALUES ('$vehicle_id','',MOW(),datetime('now', 'localtime'),'$id','$number')";
  11. $db->exec("INSERT INTO customer (type,created_at,updated_at,name,credit_sale) VALUES ('',datetime('now', 'localtime'),datetime('now', 'localtime'),'$username','$creditSale');");
  12. // $db->exec($sql2);
  13. echo '<script>window.location.href="index.php"</script>';
  14. }
  15. ?>
  16. <style type="text/css">
  17. .addForm {
  18. display: none;
  19. }
  20. </style>
  21. <div class="container addForm" id="addForm">
  22. <form class="form-horizontal" action="" method="post">
  23. <div class="form-group">
  24. <label class="control-label col-sm-2"> Name </label>
  25. <div class="col-sm-10">
  26. <input type="text" name="addusername">
  27. </div>
  28. </div>
  29. <div class="form-group">
  30. <label class="control-label col-sm-2"> Credit Sale</label>
  31. <div class="col-sm-10">
  32. <input type="checkbox" name="addcreditSale">
  33. </div>
  34. </div>
  35. <div class="form-group">
  36. <div class="col-sm-offset-2 col-sm-10">
  37. <input type="submit" class="btn btn-default" value="Submit" name="addCustomer">
  38. </div>
  39. </div>
  40. </form>
  41. </div>