Edit.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. require "connectionDb.php";
  3. if (isset($_POST['edit']) && isset($_POST['id']) && isset($_POST['username']) ) {
  4. $id = $_POST['id'];
  5. $username = $_POST['username'];
  6. $creditSale = $_POST['creditSale'];
  7. //$vehicle_id = $_POST['vehicle_id'];
  8. //$number = $_POST['number'];
  9. $sql ="UPDATE customer SET name='$username',credit_sale='$creditSale' WHERE id='$id'";
  10. //$sql2 ="UPDATE vehicle SET number='$number' WHERE id='$vehicle_id'";
  11. $db->exec($sql);
  12. //$db->exec($sql2);
  13. echo '<script>window.location.href="customers.php"</script>';
  14. }
  15. ?>
  16. <style type="text/css">
  17. .editForm {
  18. display: none;
  19. }
  20. </style>
  21. <div class="container editForm" id="editForm">
  22. <form class="form-horizontal" action="" method="post">
  23. <input type="number" name="id" id="id" hidden="hidden">
  24. <div class="form-group">
  25. <label class="control-label col-sm-2"> Name </label>
  26. <div class="col-sm-10">
  27. <input id="username" type="text" name="username">
  28. </div>
  29. </div>
  30. <div class="form-group">
  31. <label class="control-label col-sm-2"> Credit Sale</label>
  32. <div class="col-sm-10">
  33. <!-- <input id="creditSaleOn" type="checkbox" name="creditSale">
  34. <input id="creditSaleOff" type="checkbox" name="creditSale"> -->
  35. <input id="creditSaleOn" type="radio" name="creditSale" value="1"> Yes<br>
  36. <input id="creditSaleOff" type="radio" name="creditSale" value="0"> No<br>
  37. </div>
  38. </div>
  39. <!-- <input type="number" name="vehicle_id" id="vehicle_id" hidden="hidden">
  40. <div class="form-group">
  41. <label class="control-label col-sm-2"> Number</label>
  42. <div class="col-sm-10">
  43. <input id="number" type="text" name="number">
  44. </div>
  45. </div> -->
  46. <div class="form-group">
  47. <div class="col-sm-offset-2 col-sm-10">
  48. <input type="submit" name="edit" value="Submit">
  49. <input type="button" value="Cancel" onclick="document.getElementById('editVForm').style.display = 'none';">
  50. </div>
  51. </div>
  52. </form>
  53. </div>