Online Course

AY04 - Membuat Pengelolan Data Ongkos Kirim

Membuat Pengelolan Data Ongkos Kirim di Halaman Admin

ikuti langkah berikut ini

Pertama, Buat tabel baru dengan nama tb_ongkir di database anda

Struktur tb_ongkir seperti ini

tb_ongkir

Kedua, Buat file baru dengan nama ongkir.php simpan di folder ADMINWEB

isi dari file ongkir.php seperti ini

<?php
//pemanggilan file metatag
include "setting_metatag.php";

//pemanggilan file navbar
include "setting_navbar.php";
?>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Daftar Harga Ongkir
                            <a href="input_ongkir.php" title="Input data"><button name="input" class="btn btn-primary pull-right"><i class="fa fa-plus fa-fw"></i> Tambah Data</button></a>

                        </h3>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar Harga Ongkir
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <!-- .row -->
                <div class="row">

                <!-- .col lg 12 -->
                    <div class="col-lg-12">

                    <!-- panel . (Pelajari cara membuat panel di bootstrap yah)-->
                        <div class="panel panel-default">

                        <!-- panel heading -->
                            <div class="panel-heading">
                            Daftar Harga Ongkos Kirim Se Indonesia
                            </div>
                        <!-- /.panel heading -->

                        <!-- panel body -->
                            <div class="panel-body">

                            <!-- /.tabel responsive -->
                                <div class="table-responsive">
                                    <table class="table table-bordered table-hover table-striped">
                                        <thead>
                                            <tr>
                                                <th>No</th>
                                                <th>Agen</th>
                                                <th>Tujuan</th>
                                                <th>Estimasi</th>
                                                <th>Harga/Kg</th>
                                                <th>Action</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $pg = isset( $_GET['pg'] ) ? $_GET['pg'] : "";
                                        $batas = 20; /*batas tampilan setiap halaman*/
                                        if ( empty( $pg ) ) {
                                        $posisi = 0;
                                        $pg = 1;
                                        } else {
                                        $posisi = ( $pg - 1 ) * $batas;
                                        }
                                        /*Jika variabel $pg kosong maka akan menampilkan halaman pertama dengan batas baris 10*/

                                        $ambildata=mysqli_query($conect, "select*from tb_ongkir, tb_kurir, tb_kabupaten, tb_provinsi where tb_ongkir.id_kurir=tb_kurir.id_kurir and tb_ongkir.id_kabupaten=tb_kabupaten.id_kabupaten and tb_kabupaten.id_provinsi=tb_provinsi.id_provinsi order by tb_kabupaten.nama_kabupaten asc limit $posisi, $batas");
                                        $jumlah=mysqli_num_rows($ambildata);  /*mysql_num_rows untuk menghitung total baris di tabel databse*/
                                        if($jumlah == 0){  //jika tidak ada data
                                            ?>
                                        <tr>
                                            <td colspan="6">Tidak Terdapat Data</td>
                                        </tr>
                                        <?php
                                        }else{
                                        //jika ada data di tb_brand
                                        while($a=mysqli_fetch_array($ambildata)){ /*mysql_fetch array untuk mengambil data di setiap field di tabel databse*/
                                        ?>
                                        <tr>
                                            <td><?php echo $posisi=$posisi+1;?></td>
                                            <td><?php echo $a['nama_kurir'];?></td>
                                            <td><?php echo $a['nama_kabupaten'];?>, <?php echo $a['nama_provinsi'];?></td>
                                            <td><?php echo $a['estimasi'];?></td>
                                            <td><?php echo number_format($a['harga']);?></td>
                                            <td><a href="hapus_ongkir.php?id_ongkir=<?php echo $a['id_ongkir'];?>" onclick="return confirm('Yakin akan meghapus data ini')" title="Hapus data"><button class="btn btn-danger btn-sm"><i class="fa fa-trash-o fa-fw"></i> Hapus</button></a>
                                            <a href="edit_ongkir.php?id_ongkir=<?php echo $a['id_ongkir'];?>" title="Edit data"><button class="btn btn-primary btn-sm"><i class="fa fa-pencil-square-o fa-fw"></i> Edit</button> </a>
                                            </td>
                                        </tr>
                                        <?php
                                            }
                                        }
                                        ?>
                                        </tbody>
                                    </table>
                                </div>
                                <!-- /.tabel responsive -->

                                <div class="text-center">
                                    <?php
                                //script paging, untuk menampikan setiap halaman
                                $jml_data = mysqli_num_rows(mysqli_query($conect, "select*from tb_kategori order by id_kategori desc"));
                                $JmlHalaman = ceil($jml_data/$batas); //ceil digunakan untuk pembulatan keatas
                                if($jml_data != 0){
                                if ( $pg > 1 ) {
                                $link = $pg-1;
                                $prev = "<a href='?pg=$link'><button name='prev' class='btn btn-primary btn-sm'>Prev</button></a> ";
                                } else {
                                $prev = "<button name='prev' class='btn btn-default btn-sm'>Prev </button> ";
                                }
                                $nmr = '';
                                for ( $i = 1; $i<= $JmlHalaman; $i++ ){

                                if ( $i == $pg ) {
                                $nmr .= "<button name='prev' class='btn btn-primary btn-sm'>$i</button> ";
                                } else {
                                $nmr .= "<a href='?pg=$i'><button name='prev' class='btn btn-default btn-sm'>$i</button></a> ";
                                }
                                }
                                if ( $pg < $JmlHalaman ) {
                                $link = $pg + 1;
                                $next = "<a href='?pg=$link'><button name='prev' class='btn btn-primary btn-sm'>Next</button></a> ";
                                } else {
                                $next = "<button name='prev' class='btn btn-default btn-sm'>Next</button> ";
                                }
                                echo $prev.$nmr.$next;
                                ?>
                                <br><br>
                                <span class="text-muted">Menampilkan <?php echo $jumlah; ?> dari <?php echo $jml_data; ?> Record </span>
                                <?php
                                }
                                ?>
                                </div>
                            </div>
                            <!-- /.panel body -->

                        </div>
                        <!-- /.panel -->

                    </div>
                    <!-- /.col lg 12-->

                </div>
                <!-- /.row -->


           </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

<?php
//pemanggilan file setting footer
include "setting_footer.php";

?>

Hasil dari file tersebut seperti ini

ongkir

Ketiga, Buat file baru dengan nama input_ongkir.php simpan di folder ADMINWEB

isi dari file input_ongkir.php seperti ini

<?php
//pemanggilan file metatag
include "setting_metatag.php";

//pemanggilan file navbar
include "setting_navbar.php";
?>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Tambah Harga Ongkir
                        </h3>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar Harga Ongkir
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                //variabel setiap input di form
                $kurir=mysqli_real_escape_string($conect, $_POST['kurir']);  //variabel dari name input kurir
                $harga=mysqli_real_escape_string($conect, $_POST['harga']);  //variabel dari name input harga
                $estimasi=mysqli_real_escape_string($conect, $_POST['estimasi']);  //variabel dari name input estimasi
                $provinsi=mysqli_real_escape_string($conect, $_POST['provinsi']);   //variabel prov
                $kabupaten=mysqli_real_escape_string($conect, $_POST['kabupaten']);   //variabel kabptn

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($kurir)){  //jika prov kosong
                        $er_kurir="<div class='alert alert-warning alert-dismissable'>
                        <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                        <i class='fa fa-info-circle'></i> Pilih Agen Kurir !</div>";
                    }
                elseif(empty($provinsi)){  //jika prov kosong
                        $er_provinsi="<div class='alert alert-warning alert-dismissable'>
                        <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                        <i class='fa fa-info-circle'></i> Masukan Nama Provinsi !</div>";
                    }
                elseif(empty($kabupaten)){  //jika kabupaten kosong
                        $er_kabupaten="<div class='alert alert-warning alert-dismissable'>
                        <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                        <i class='fa fa-info-circle'></i> Masukan Nama Kabupaten !</div>";
                    }
                elseif(empty($harga)){  //jika field nama kosong
                $er_harga="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Masukan Harga </div>";
                }
                else{
                $save=mysqli_query($conect, "INSERT INTO tb_ongkir (id_ongkir,estimasi,harga,id_kurir,id_kabupaten)values('','$estimasi','$harga','$kurir','$kabupaten')") or die(mysql_error());
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Disimpan');document.location='ongkir.php'</script>";
                }
                else{  //jika simpan gagal
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Error</div>";
                }

                }
                }
                ?>
                <!-- .row -->
                <div class="row">

                <!-- .col lg 12 -->
                    <div class="col-lg-12">

                    <!-- panel . (Pelajari cara membuat panel di bootstrap yah)-->
                        <div class="panel panel-default">

                        <!-- panel heading -->
                            <div class="panel-heading">
                                <a href="ongkir.php" title="Input data"><button name="input" class="btn btn-primary">Kembali</button></a>
                            </div>
                        <!-- /.panel heading -->

                        <!-- panel body -->
                            <div class="panel-body">

                            <!-- /.form menggunakan form group, pelajari cara membuat form di bootstrap-->

                            <form action="" method="post" enctype="multipart/form-data" role="form">
                            <?php echo $error;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Agen Kurir</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <select class="form-control" name="kurir" id="kurir">
                                        <option value="">-- Pilih --</option>
                                        <?php
                                        $cek=mysqli_query($conect, "select*from tb_kurir order by nama_kurir");
                                        while($ye=mysqli_fetch_array($cek)){
                                        if($ye['id_kurir'] == $_POST['kurir']){
                                        ?>
                                        <option value="<?php echo $ye['id_kurir'];?>" selected>
                                        <?php echo $ye['nama_kurir'];?>
                                        </option>
                                        <?php
                                        }else{
                                        ?>
                                        <option value="<?php echo $ye['id_kurir'];?>">
                                        <?php echo $ye['nama_kurir'];?>
                                        </option>
                                        <?php
                                        }
                                        }
                                        ?>
                                </select>
                                </div>
                           </div>
                           <?php echo $er_kurir;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Provinsi</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <select class="form-control" name="provinsi" id="provinsi">
                                        <option value="">-- Pilih --</option>
                                        <?php
                                        $cek=mysqli_query($conect, "select*from tb_provinsi order by nama_provinsi");
                                        while($ye=mysqli_fetch_array($cek)){
                                        if($ye['id_provinsi'] == $_POST['provinsi']){
                                        ?>
                                        <option value="<?php echo $ye['id_provinsi'];?>" selected>
                                        <?php echo $ye['nama_provinsi'];?>
                                        </option>
                                        <?php
                                        }else{
                                        ?>
                                        <option value="<?php echo $ye['id_provinsi'];?>">
                                        <?php echo $ye['nama_provinsi'];?>
                                        </option>
                                        <?php
                                        }
                                        }
                                        ?>
                                </select>
                                </div>
                           </div>
                           <?php echo $er_provinsi;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Kabupaten</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <select class="form-control" name="kabupaten" id="kabupaten">
                                        <option value="">-- Pilih --</option>
                                        <?php
                                        $kab=mysqli_query($conect, "select*from tb_kabupaten order by nama_kabupaten");
                                        while($kb=mysqli_fetch_array($kab)){
                                        if($kb['id_kabupaten'] == $_POST['kabupaten']){
                                        ?>
                                        <option value="<?php echo $kb['id_kabupaten'];?>" selected>
                                        <?php echo $kb['nama_kabupaten'];?>
                                        </option>
                                        <?php
                                        }
                                        }
                                        ?>
                                </select>
                                </div>
                            </div>
                            <?php echo $er_kabupaten;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Harga/Kg</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input type="text" class="form-control" placeholder="Harga Per Kg" name="harga" value="<?php echo $_POST['harga'];?>" maxlength="100" autocomplete="off" autofocus>
                            </div>
                            </div>
                            <?php echo $er_estimasi;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Estimasi</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input type="text" class="form-control" placeholder="Estimasi Waktu" name="estimasi" value="<?php echo $_POST['estimasi'];?>" maxlength="100" autocomplete="off" autofocus>
                            </div>
                            </div>
                            <?php echo $er_estimasi;?>

                            <button type="submit" name="simpan" class="btn btn-success">Simpan</button>

                            </form>
                                <!-- /.form -->
                            </div>
                            <!-- /.panel body -->

                        </div>
                        <!-- /.panel -->

                    </div>
                    <!-- /.col lg 12-->

                </div>
                <!-- /.row -->


           </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

<?php
//pemanggilan file setting footer
include "setting_footer.php";

?>
<script type="text/javascript">
$(document).ready(function () {

    $(document).on('change', '#provinsi', function () {
        var p = this.value;
        $.ajax({
            url: "kabupaten.php",
            method: "POST",
            data: { p: p },
            success: function (data) {
                $('#kabupaten').html(data);
            }
        })
    });
});

</script>

Hasil dari file tersebut seperti ini

input-ongkir

Kedua, Buat file baru dengan nama edit_ongkir.php simpan di folder ADMINWEB

isi dari file edit_ongkir.php seperti ini

<?php
//pemanggilan file metatag
include "setting_metatag.php";

//pemanggilan file navbar
include "setting_navbar.php";
?>

        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Ubah Harga Ongkir
                        </h3>
                        <ol class="breadcrumb">
                            <li class="active">
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar Harga Ongkir
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                //ambil data berdasarkan id
                $tampildata=mysqli_query($conect, "select*from tb_ongkir, tb_kurir, tb_kabupaten, tb_provinsi where tb_ongkir.id_ongkir='$_GET[id_ongkir]' and tb_ongkir.id_kurir=tb_kurir.id_kurir and tb_ongkir.id_kabupaten=tb_kabupaten.id_kabupaten and tb_kabupaten.id_provinsi=tb_provinsi.id_provinsi");
                $b=mysqli_fetch_array($tampildata);
                $idp = $b['id_provinsi']; //variabel dari id_provinsi
                $idkb = $b['id_kabupaten'];  //variabel dari id_kabupaten
                $idkur = $b['id_kurir'];  //variabel dari id_kurir

                //variabel setiap input di form
                $kurir=mysqli_real_escape_string($conect, $_POST['kurir']);  //variabel dari name input kurir
                $harga=mysqli_real_escape_string($conect, $_POST['harga']);  //variabel dari name input harga
                $estimasi=mysqli_real_escape_string($conect, $_POST['estimasi']);  //variabel dari name input estimasi
                $provinsi=mysqli_real_escape_string($conect, $_POST['provinsi']);   //variabel prov
                $kabupaten=mysqli_real_escape_string($conect, $_POST['kabupaten']);   //variabel kabptn

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($kurir)){  //jika prov kosong
                        $er_kurir="<div class='alert alert-warning alert-dismissable'>
                        <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                        <i class='fa fa-info-circle'></i> Pilih Agen Kurir !</div>";
                    }
                elseif(empty($provinsi)){  //jika prov kosong
                        $er_provinsi="<div class='alert alert-warning alert-dismissable'>
                        <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                        <i class='fa fa-info-circle'></i> Masukan Nama Provinsi !</div>";
                    }
                elseif(empty($kabupaten)){  //jika kabupaten kosong
                        $er_kabupaten="<div class='alert alert-warning alert-dismissable'>
                        <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                        <i class='fa fa-info-circle'></i> Masukan Nama Kabupaten !</div>";
                    }
                elseif(empty($harga)){  //jika field nama kosong
                $er_harga="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Masukan Harga </div>";
                }
                else{
                $save=mysqli_query($conect, "UPDATE tb_ongkir set estimasi='$estimasi', harga='$harga', id_kurir='$kurir', id_kabupaten='$kabupaten' where id_ongkir='$_GET[id_ongkir]'") or die(mysql_error());
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Disimpan');document.location='ongkir.php'</script>";
                }
                else{  //jika simpan gagal
                $error="<div class='alert alert-warning alert-dismissable'>
                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                <i class='fa fa-info-circle'></i> Error</div>";
                }

                }
                }
                ?>
                <!-- .row -->
                <div class="row">

                <!-- .col lg 12 -->
                    <div class="col-lg-12">

                    <!-- panel . (Pelajari cara membuat panel di bootstrap yah)-->
                        <div class="panel panel-default">

                        <!-- panel heading -->
                            <div class="panel-heading">
                                <a href="ongkir.php" title="Input data"><button name="input" class="btn btn-primary">Kembali</button></a>
                            </div>
                        <!-- /.panel heading -->

                        <!-- panel body -->
                            <div class="panel-body">

                            <!-- /.form menggunakan form group, pelajari cara membuat form di bootstrap-->

                            <form action="" method="post" enctype="multipart/form-data" role="form">
                            <?php echo $error;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Agen Kurir</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <select class="form-control" name="kurir" id="kurir">
                                        <option value="">-- Pilih --</option>
                                        <?php
                                        $cek=mysqli_query($conect, "select*from tb_kurir order by nama_kurir");
                                        while($ye=mysqli_fetch_array($cek)){
                                        if($ye['id_kurir'] == $idkur){
                                        ?>
                                        <option value="<?php echo $ye['id_kurir'];?>" selected>
                                        <?php echo $ye['nama_kurir'];?>
                                        </option>
                                        <?php
                                        }else{
                                        ?>
                                        <option value="<?php echo $ye['id_kurir'];?>">
                                        <?php echo $ye['nama_kurir'];?>
                                        </option>
                                        <?php
                                        }
                                        }
                                        ?>
                                </select>
                                </div>
                           </div>
                           <?php echo $er_kurir;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Provinsi</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <select class="form-control" name="provinsi" id="provinsi">
                                        <option value="">-- Pilih --</option>
                                        <?php
                                        $cek=mysqli_query($conect, "select*from tb_provinsi order by nama_provinsi");
                                        while($ye=mysqli_fetch_array($cek)){
                                        if($ye['id_provinsi'] == $idp){
                                        ?>
                                        <option value="<?php echo $ye['id_provinsi'];?>" selected>
                                        <?php echo $ye['nama_provinsi'];?>
                                        </option>
                                        <?php
                                        }else{
                                        ?>
                                        <option value="<?php echo $ye['id_provinsi'];?>">
                                        <?php echo $ye['nama_provinsi'];?>
                                        </option>
                                        <?php
                                        }
                                        }
                                        ?>
                                </select>
                                </div>
                           </div>
                           <?php echo $er_provinsi;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Kabupaten</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <select class="form-control" name="kabupaten" id="kabupaten">
                                        <option value="">-- Pilih --</option>
                                        <?php
                                        $kab=mysqli_query($conect, "select*from tb_kabupaten where id_provinsi='$idp' order by nama_kabupaten");
                                        while($kb=mysqli_fetch_array($kab)){
                                        if($kb['id_kabupaten'] == $idkb){
                                        ?>
                                        <option value="<?php echo $kb['id_kabupaten'];?>" selected>
                                        <?php echo $kb['nama_kabupaten'];?>
                                        </option>
                                        <?php
                                        }else{
                                        ?>
                                        <option value="<?php echo $kb['id_kabupaten'];?>">
                                        <?php echo $kb['nama_kabupaten'];?>
                                        </option>
                                        <?php
                                        }
                                        }
                                        ?>
                                </select>
                                </div>
                            </div>
                            <?php echo $er_kabupaten;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Harga/Kg</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input type="text" class="form-control" placeholder="Harga Per Kg" name="harga" value="<?php echo $b['harga'];?>" maxlength="100" autocomplete="off" autofocus>
                            </div>
                            </div>
                            <?php echo $er_estimasi;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Estimasi</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input type="text" class="form-control" placeholder="Estimasi Waktu" name="estimasi" value="<?php echo $b['estimasi'];?>" maxlength="100" autocomplete="off" autofocus>
                            </div>
                            </div>
                            <?php echo $er_estimasi;?>

                            <button type="submit" name="simpan" class="btn btn-success">Simpan</button>

                            </form>
                                <!-- /.form -->
                            </div>
                            <!-- /.panel body -->

                        </div>
                        <!-- /.panel -->

                    </div>
                    <!-- /.col lg 12-->

                </div>
                <!-- /.row -->


           </div>
            <!-- /.container-fluid -->

        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

<?php
//pemanggilan file setting footer
include "setting_footer.php";

?>
<script type="text/javascript">
$(document).ready(function () {

    $(document).on('change', '#provinsi', function () {
        var p = this.value;
        $.ajax({
            url: "kabupaten.php",
            method: "POST",
            data: { p: p },
            success: function (data) {
                $('#kabupaten').html(data);
            }
        })
    });
});

</script>

Hasil dari file tersebut seperti ini

edit-ongkir

Kedua, Buat file baru dengan nama hapus_ongkir.php simpan di folder ADMINWEB

isi dari file hapus_ongkir.php seperti ini

<?php
session_start();
//panggil koneksi
include "../assets/relasi/koneksi.php";

$id=$_GET['id_ongkir'];  //dapatkan id

if(isset($id)){ //jika ada id
//hapus data di tabel
$hapus=mysqli_query($conect, "DELETE from tb_ongkir where id_ongkir='$id'");
//jika hapus berhasil
if($hapus){
    echo"<script>alert('Data Berhasil di Hapus');document.location='ongkir.php'</script>";
}
else{ //jika gagal
    echo"<script>alert('Error Bos !!');document.location='ongkir.php'</script>";
}

}
?>

Oke

 

 

Develindo Web | Tutorial Pemrograman Website