SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | - | include'konpros.php'; |
| 2 | + | include 'konpros.php'; |
| 3 | - | |
| 3 | + | |
| 4 | - | session_start(); |
| 4 | + | session_start(); |
| 5 | - | if (isset($_SESSION['username'])) {
|
| 5 | + | if (isset($_SESSION['username'])) {
|
| 6 | - | $username = $_SESSION['username']; |
| 6 | + | $username = $_SESSION['username']; |
| 7 | - | header ('location:');
|
| 7 | + | } else if (empty($_SESSION['username'])) {
|
| 8 | - | }else if (empty($_SESSION['username'])) {
|
| 8 | + | header ('location: ../../../login/login.php');
|
| 9 | - | header ('location:../../../login/login.php');
|
| 9 | + | } |
| 10 | ||
| 11 | $all_success = true; | |
| 12 | - | for ($i=0; $i++) {
|
| 12 | + | |
| 13 | - | $tgl = $_POST['tgl_input'][$i]; |
| 13 | + | if ( isset($_POST['tgl_input']) && is_array($_POST['tgl_input']) ) { //Pastikan ada yg disubmit
|
| 14 | - | $nm_pemohon = $_POST['nama_pemohon'][$i]; |
| 14 | + | foreach ($_POST['tgl_input'] as $key => $value) { //looping baris data
|
| 15 | - | $nm_instansi = $_POST['nama_instansi'][$i]; |
| 15 | + | $tgl = $_POST['tgl_input'][$key]; |
| 16 | - | $jns_data = $_POST['jenis_data'][$i]; |
| 16 | + | $nm_pemohon = $_POST['nama_pemohon'][$key]; |
| 17 | - | $jml_unit = $_POST['jumlah_unit'][$i]; |
| 17 | + | $nm_instansi = $_POST['nama_instansi'][$key]; |
| 18 | - | $jml_waktu = $_POST['jumlah_waktu'][$i]; |
| 18 | + | $jns_data = $_POST['jenis_data'][$key]; |
| 19 | - | $periode = $_POST['periode'][$i]; |
| 19 | + | $jml_unit = $_POST['jumlah_unit'][$key]; |
| 20 | - | $nm_disposisi = $_POST['nama_disposisi'][$i]; |
| 20 | + | $jml_waktu = $_POST['jumlah_waktu'][$key]; |
| 21 | - | $jns_tarif = $_POST['jenis_tarif'][$i]; |
| 21 | + | $periode = $_POST['periode'][$key]; |
| 22 | - | $hrg_total = $_POST['harga_total'][$i]; |
| 22 | + | $nm_disposisi = $_POST['nama_disposisi'][$key]; |
| 23 | $jns_tarif = $_POST['jenis_tarif'][$key]; | |
| 24 | $hrg_total = $_POST['harga_total'][$key]; | |
| 25 | ||
| 26 | - | mysqli_stmt_bind_param($refdis, 'ssssssssss', $tgl, $nm_pemohon, $nm_instansi, $jns_data, $jml_unit, $jml_waktu, $periode ,$nm_disposisi, $jns_tarif, $hrg_total); |
| 26 | + | |
| 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 | - | if ($result_dis) {
|
| 30 | + | $all_success = false; |
| 31 | - | echo "<script>alert('DATA BERHASIL DI INPUT'); window.location = 'laporansuper.php'</script>";
|
| 31 | + | |
| 32 | - | }else{
|
| 32 | + | |
| 33 | - | echo "gagal"; |
| 33 | + | } |
| 34 | ||
| 35 | if ($all_success) {
| |
| 36 | - | ?> |
| 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 | } |