donnykurnia

prosesinput.php

Feb 14th, 2017
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include 'konpros.php';
  3.  
  4. session_start();
  5. if (isset($_SESSION['username'])) {
  6. $username = $_SESSION['username'];
  7. } else if (empty($_SESSION['username'])) {
  8. header ('location: ../../../login/login.php');
  9. }
  10.  
  11. $all_success = true;
  12.  
  13. if ( isset($_POST['tgl_input']) && is_array($_POST['tgl_input']) ) { //Pastikan ada yg disubmit
  14. foreach ($_POST['tgl_input'] as $key => $value) { //looping baris data
  15. $tgl = $_POST['tgl_input'][$key];
  16. $nm_pemohon = $_POST['nama_pemohon'][$key];
  17. $nm_instansi = $_POST['nama_instansi'][$key];
  18. $jns_data = $_POST['jenis_data'][$key];
  19. $jml_unit = $_POST['jumlah_unit'][$key];
  20. $jml_waktu = $_POST['jumlah_waktu'][$key];
  21. $periode = $_POST['periode'][$key];
  22. $nm_disposisi = $_POST['nama_disposisi'][$key];
  23. $jns_tarif = $_POST['jenis_tarif'][$key];
  24. $hrg_total = $_POST['harga_total'][$key];
  25.  
  26. $refdis = mysqli_prepare($koneksi, "INSERT INTO refdisposisi(tgl_masuk, nm_pemohon, nm_instansi, data_minta, jumlah_unit, jumlah_waktu, periode, nama_disposisi, jenis_tarif, harga) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  27. mysqli_stmt_bind_param($refdis, 'ssssssssss', $tgl, $nm_pemohon, $nm_instansi, $jns_data, $jml_unit, $jml_waktu, $periode, $nm_disposisi, $jns_tarif, $hrg_total);
  28. $result_dis = mysqli_stmt_execute($refdis);
  29. if ( !$result_dis ) {
  30. $all_success = false;
  31. }
  32. }
  33. }
  34.  
  35. if ($all_success) {
  36. echo "<script>alert('SEMUA DATA BERHASIL DI INPUT'); window.location = 'laporansuper.php'</script>";
  37. } else {
  38. echo "Ada satu atau lebih insert data yg gagal";
  39. }
Advertisement
Add Comment
Please, Sign In to add comment