Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. // Panggil koneksi database
  3. require_once "config/database.php";
  4.  
  5. if (isset($_POST['simpan'])) {
  6. $nama = mysqli_real_escape_string($db, trim($_POST['nama']));
  7. $username = mysqli_real_escape_string($db, trim($_POST['username']));
  8. $password = mysqli_real_escape_string($db, trim($_POST['password']));
  9. $email = mysqli_real_escape_string($db, trim($_POST['email']));
  10.  
  11. // perintah query untuk menyimpan data ke tabel
  12. $query = mysqli_query($db, "INSERT INTO is_siswa(nama,
  13. username,
  14. password,
  15. email)
  16. VALUES('$nama',
  17. '$username',
  18. '$password',
  19. '$email')");
  20.  
  21. // cek hasil query
  22. if ($query) {
  23. // jika berhasil tampilkan pesan berhasil insert data
  24. header('location: index.php?alert=2');
  25. } else {
  26. // jika gagal tampilkan pesan kesalahan
  27. header('location: index.php?alert=1');
  28. }
  29. }
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement