Advertisement
Guest User

PHP INSERT

a guest
Sep 19th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2. include "header.template.php";
  3. ?>
  4. <!-- forminsert.php
  5. -->
  6. <form method="get" action="">
  7. ID
  8. <input name="IDPelajar" type="text"
  9. class="form-control">
  10. Nama pelajar
  11. <input name="NamaPel" type="text"
  12. class="form-control">
  13. Alamat
  14. <input name="Alamat" type="text"
  15. class="form-control">
  16. <input type="submit" value="Simpan"
  17. class="btn btn-primary">
  18. </form>
  19. <hr>
  20. <?php
  21. include "connection.php";
  22. //verify ada data tidak dalam form
  23. if (isset($_GET['IDPelajar'])){
  24.     //capture all data
  25.     $id=$_GET['IDPelajar'];
  26.     $nama=$_GET['NamaPel'];
  27.     $alamat=$_GET['Alamat'];
  28. //sql command to create new record
  29.     $sql="INSERT INTO pelajar
  30.     (IDPelajar, NamaPel, Alamat)
  31.     VALUES
  32.     ('$id','$nama','$alamat')";
  33.     //run sql
  34.     $rs = mysqli_query($db, $sql);
  35.     if($rs==true){
  36.         echo "Rekod jaya disimpan";
  37.     }
  38. }
  39. ?>
  40.  
  41. <?php
  42. include "footer.template.php";
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement