Online Course

DNR04 – Tutorial Membuat Pengaturan Daftar Guru & Karyawan

Tutorial Membuat Pengaturan Daftar Guru & Karyawan

Halaman pengaturan guru & karyawan memudahkan admin dalam mengelola data guru atau karyawan secara dinamis.

Silahkan anda buat folder dengan nama guru di dalam folder images

Bagian 1 : Buat tabel baru di database dengan nama tb_guru

Struktur tabel dari tb_guru seperti ini

tb-guru

Bagian 2 : Buka file setting_metatag.php

Ganti script menjadi seperti ini

<?php
//session dimulai
session_start();
//abaikan error pada browser
error_reporting(0);
//panggil file koneksi untuk mengkoneksinkan dengan database
include "../assets/relasi/koneksi.php";
//panggil file security untuk mengecek session admin
include "security.php";
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="keywords" content="<?php echo $iweb['katakunci'];?>">
        <meta name="description" content="<?php echo $iweb['deskripsi'];?>" />
        <meta name="author" content="<?php echo $iweb['pembuat'];?>">
        <title><?php echo $iweb['nama_website'];?></title>
        <link rel="Shortcut Icon" href="<?php echo $hostname;?>/assets/images/logo/<?php echo $iweb['logo'];?>" type="image/x-icon" />
        <!-- Bootstrap core CSS -->
        <link href="<?php echo $hostname;?>/assets/css/bootstrap.css" rel="stylesheet">
        <!-- Custom styles template ini-->
        <link href="<?php echo $hostname;?>/assets/css/style_admin.css" rel="stylesheet">

        <!-- Custom Fonts Awesome-->
        <link href="<?php echo $hostname;?>/assets/fonts/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

        <link href="<?php echo $hostname;?>/assets/css/datepicker.min.css" rel="stylesheet">

        <script src="<?php echo $hostname;?>/assets/js/jquery.min.js"></script>
        <script src="<?php echo $hostname;?>/assets/js/bootstrap.js"></script>
        <script src="<?php echo $hostname;?>/assets/js/bootstrap-datepicker.min.js"></script>

</head>

<body>
<div id="wrapper">

Bagian 3 : Buka file setting_footer.php

Ganti script menjadi seperti ini

<script>
$(document).ready(function () {
    $('#datePicker')
        .datepicker({
            format: 'yyyy-mm-dd'
        })
    });
</script>

<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
        <script src="<?php echo $hostname;?>/assets/js/ie10-viewport-bug-workaround.js"></script>
    </body>
</html>

Bagian 4 : Buka file setting_navbar.php

Ganti script menjadi seperti ini

<!-- Bagian Navbar / menu bagian atas dan samping-->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#"><span class="fa fa-laptop"></span> Ruang Admin</a>
    </div>
    <ul class="nav navbar-right top-nav">
            <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="label label-danger">42</span> <i class="fa fa-envelope"></i> <b class="caret"></b></a>
                    <ul class="dropdown-menu message-dropdown">
                        <li class="message-preview">
                            <a href="#">
                                <div class="media">
                                    <div class="media-body">
                                        <h5 class="media-heading"><strong>John Smith</strong>
                                        </h5>
                                        <p class="small text-muted"><i class="fa fa-clock-o"></i> Yesterday at 4:32 PM</p>
                                        <p>Lorem ipsum dolor sit amet, consectetur...</p>
                                    </div>
                                </div>
                            </a>
                        </li>
                        <li class="message-preview">
                            <a href="#">
                                <div class="media">
                                    <div class="media-body">
                                        <h5 class="media-heading"><strong>John Smith</strong>
                                        </h5>
                                        <p class="small text-muted"><i class="fa fa-clock-o"></i> Yesterday at 4:32 PM</p>
                                        <p>Lorem ipsum dolor sit amet, consectetur...</p>
                                    </div>
                                </div>
                            </a>
                        </li>
                        <li class="divider"></li>
                        <li class="message-footer">
                            <a href="#">Read All New Messages</a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-bell"></i> <b class="caret"></b></a>
                    <ul class="dropdown-menu alert-dropdown">
                        <li>
                            <a href="#">Alert Name <span class="label label-default">Alert Badge</span></a>
                        </li>
                        <li>
                            <a href="#">Alert Name <span class="label label-primary">Alert Badge</span></a>
                        </li>
                        <li>
                            <a href="#">Alert Name <span class="label label-success">Alert Badge</span></a>
                        </li>
                        <li class="divider"></li>
                        <li>
                            <a href="#">View All</a>
                        </li>
                    </ul>
                </li>
            <li class="dropdown">
                <a aria-expanded="false" href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo $admin['nama_admin'];?><span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="logout.php">Logout</a></li>

                </ul>
            </li>
        </ul>
    <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav side-nav">
            <li><a href="home.php">Home</a></li>
            <li class="dropdown">
                <a aria-expanded="false" href="#" class="dropdown-toggle" data-toggle="dropdown">Data Pokok <i class="glyphicon glyphicon-chevron-down pull-right"></i></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="siswa.php">Data Siswa</a></li>
                    <li><a href="guru.php">Data Guru</a></li>
                </ul>
            </li>
            <li class="dropdown">
                <a aria-expanded="false" href="#" class="dropdown-toggle" data-toggle="dropdown">Pengaturan <i class="glyphicon glyphicon-chevron-down pull-right"></i></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="identitas.php">Identitas Web</a></li>
                    <li><a href="infobis.php">Identitas Sekolah</a></li>
                    <li><a href="slider.php">Foto Slider</a></li>
                    <li><a href="admin.php">Akun Admin</a></li>
                </ul>
            </li>

        </ul>
    </div>
</nav>
<!-- Bagian Navbar / menu bagian atas dan samping-->

Bagian 5: Buat file baru beri nama guru.php simpan di folder ADMINWEB

Isi dari file guru.php seperti ini

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

//pemanggilan file navbar
include "setting_navbar.php";
?>
<style type="text/css">
th{
    min-width:70px;
}
</style>
        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Daftar Guru & Karyawan
                        </h3>
                        <ol class="breadcrumb">
                            <li>
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li>
                                 <i class="fa fa-list"></i> Data Pokok
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar Guru & Karyawan
                            </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">
                            <div class="col-lg-6">
                            <a href="input_guru.php" title="Input data"><button name="input" class="btn btn-primary"><i class="fa fa-plus-square-o fa-fw"></i> Input</button></a>
                            </div>
                            <div class="col-lg-6">
                            <!-- form pencarian produk -->
                            <form action="cari_guru.php" method="get" class="form-inline text-right">
                            <input type="text" class="form-control" name="qw" placeholder="Cari Guru" required>
                            <button type="submit" class="btn btn-primary">Cari</button>
                            </form>
                            <!-- form pencarian produk -->
                            </div>
                            <div style="clear:both;"></div>
                            </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>NIP</th>
                                                <th>Nama Lengkap</th>
                                                <th>Tempat Lahir</th>
                                                <th>Tanggal Lahir</th>
                                                <th>L/P</th>
                                                <th>Alamat</th>
                                                <th>Telp</th>
                                                <th>Email</th>
                                                <th>NIK</th>
                                                <th>Menikah</th>
                                                <th>Pendidikan</th>
                                                <th>Jabatan</th>
                                                <th>Status</th>
                                                <th>Foto</th>
                                                <th>Action</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $pg = isset( $_GET['pg'] ) ? $_GET['pg'] : "";
                                        $batas = 25; /*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_guru order by nip_guru desc 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="16">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['nip_guru'];?></td>
                                            <td><?php echo $a['nama_guru'];?></td>
                                            <td><?php echo $a['tempatlahir_guru'];?></td>
                                            <td><?php echo tgl_indo($a['tgllahir_guru']);?></td>
                                            <td><?php echo $a['gender_guru'];?></td>
                                            <td><?php echo $a['alamat_guru'];?></td>
                                            <td><?php echo $a['telp_guru'];?></td>
                                            <td><?php echo $a['email_guru'];?></td>
                                            <td><?php echo $a['nik_guru'];?></td>
                                            <td><?php echo $a['status_menikah'];?></td>
                                            <td><?php echo $a['pend_guru'];?></td>
                                            <td><?php echo $a['jabatan_guru'];?></td>
                                            <td><?php echo $a['status_guru'];?></td>
                                            
                                            <td><img src="<?php echo $hostname;?>/assets/images/guru/<?php echo $a['foto_guru'];?>" class="img-thumbnail" style="width:60px; height:60px;"></td>
                                            <td><a href="hapus_guru.php?nip_guru=<?php echo $a['nip_guru'];?>" 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_guru.php?nip_guru=<?php echo $a['nip_guru'];?>" 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_guru order by nip_guru 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 guru.php jika di coba dibrowser seperti ini

daftar-guru

 

Bagian 6 : Buat file baru beri nama input_guru.php simpan di folder ADMINWEB

Isi dari file input_guru.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 Data Guru & Karyawan
                        </h3>
                        <ol class="breadcrumb">
                            <li>
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li>
                                 <i class="fa fa-list"></i> Data Pokok
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar Guru & Karyawan
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);  //variabel dari name input nama
                $nip=mysqli_real_escape_string($conect, $_POST['nip']);
                $nik=mysqli_real_escape_string($conect, $_POST['nik']);
                $email=mysqli_real_escape_string($conect, $_POST['email']);
                $telp=mysqli_real_escape_string($conect, $_POST['telp']);
                $status=mysqli_real_escape_string($conect, $_POST['status']);
                $pend=mysqli_real_escape_string($conect, $_POST['pend']);
                $jabatan=mysqli_real_escape_string($conect, $_POST['jabatan']);
                $tempat=mysqli_real_escape_string($conect, $_POST['tempat']);
                $tgllahir=mysqli_real_escape_string($conect, $_POST['tanggal']);
                $alamat=mysqli_real_escape_string($conect, $_POST['alamat']);
                $gender=mysqli_real_escape_string($conect, $_POST['gender']);
                $menikah=mysqli_real_escape_string($conect, $_POST['menikah']);
                $pass = $tgllahir;

                $foto=$_FILES['foto']['tmp_name'];               //variabel dari temporary foto
                $nama_foto=$_FILES ['foto']['name'];             //variabel dari name input foto
                $type=$_FILES['foto']['type'];                   //variabel dari type foto
                $ukuran=$_FILES['foto']['size'];                 //variabel dari ukuran foto
                $files= strtolower(substr(strrchr($nama_foto,"."),1)); //variabel untuk extensi file

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($nip)){  //jika field nama kosong
                $er_nip="<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 NIP guru </div>";
                }
                elseif(empty($nik)){  //jika field nama kosong
                $er_nik="<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 NIK Guru </div>";
                }
                elseif(empty($nama)){  //jika field nama kosong
                $er_nama="<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 Guru </div>";
                }
                elseif(empty($gender)){  //jika field nama kosong
                $er_gender="<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 Gender Guru </div>";
                }
                elseif(empty($tempat)){ //jika field url kosong
                $er_tempat="<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 Tempat Lahir</div>";
                }
                elseif(empty($tgllahir)){ //jika field url kosong
                $er_tgllahir="<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 Tanggal Lahir</div>";
                }
                elseif(empty($email)){ //jika field url kosong
                $er_email="<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 Email Guru</div>";
                }
                elseif(empty($telp)){ //jika field url kosong
                $er_telp="<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 No. Telp</div>";
                }
                elseif(empty($alamat)){ //jika field url kosong
                $er_alamat="<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 Alamat Guru</div>";
                }
                elseif(empty($pend)){ //jika field url kosong
                $er_pend="<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 Pendidikan Terakhir</div>";
                }
                elseif(empty($jabatan)){ //jika field url kosong
                $er_jabatan="<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 Jabatan Guru</div>";
                }
                elseif($menikah == ""){ //jika field url kosong
                $er_menikah="<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 status Menikah</div>";
                }
                elseif($status == ""){ //jika field url kosong
                $er_status="<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 status Kepegawaian</div>";
                }
                elseif(empty($foto)){  //jika foto kosong
                $er_foto="<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 Foto</div>";
                }
                elseif($files !="jpg" && $files !="png"){ //jika foto tidak berekstensi .jpg atau .png
                $er_foto="<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> Format Gambar yang diizinkan hanya .jpg dan .png</div>";
                }
                elseif($ukuran > 2000000){   //jika ukuran lebih besar dari 2MB
                $er_foto="<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> Maksimal ukuran gambar 2MB </div>";
                }
                elseif(strlen($nama_foto) > 100){  //jika jumlah karakter nama foto lebih dari 100 karakter
                $er_foto="<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> Nama File Gambar Mak 100 karakter</div>";
                }
                else{ //jika semua field terpenuhi maka smpan gambar ke folder brand dan simpan data ke tb_brand
                move_uploaded_file($foto,"../assets/images/guru/$nama_foto");
                $save=mysqli_query($conect, "INSERT INTO tb_guru (nip_guru,nama_guru,alamat_guru,foto_guru,email_guru,telp_guru,status_menikah,status_guru,gender_guru,tempatlahir_guru,tgllahir_guru,pend_guru,jabatan_guru,pass_guru,nik_guru)
                values('$nip','$nama','$alamat','$nama_foto','$email','$telp','$menikah','$status','$gender','$tempat','$tgllahir','$pend','$jabatan','$pass','$nik')") or die(mysqli_error($conect));
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Ditambahkan');document.location='guru.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> Penyimpanan Gagal, ulangi lagi</div>";
                }

                }
                }
                if($_POST['gender'] == "L"){
                    $check1='checked';
                }elseif($_POST['gender'] == "P"){
                    $check2='checked';
                }
                
                if($_POST['menikah'] == "Ya"){
                    $ya='selected';
                }elseif($_POST['menikah'] == "Belum"){
                    $no='selected';
                }

                if($_POST['status'] == "PNS"){
                    $pns='selected';
                }elseif($_POST['status'] == "PNS Diperbantukan"){
                    $pnsdip='selected';
                }elseif($_POST['status'] == "PNS Depag"){
                    $pnsdep='selected';
                }elseif($_POST['status'] == "GTY/PTY"){
                    $gty='selected';
                }elseif($_POST['status'] == "GTT/PTT"){
                    $gtt='selected';
                }elseif($_POST['status'] == "Guru Bantu Pusat"){
                    $gbp='selected';
                }elseif($_POST['status'] == "Guru Bantu Sekolah"){
                    $gbs='selected';
                }elseif($_POST['status'] == "Tenaga Honor"){
                    $th='selected';
                }
                
                ?>
                <!-- .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="guru.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">
                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">NIP</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nip" id="nip" placeholder="NIP" maxlength="30" value="<?php echo $_POST['nip'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nip;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">NIK</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nik" id="nik" placeholder="NIK" maxlength="30" value="<?php echo $_POST['nik'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nik;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Nama dan Gelar</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nama" id="nama" placeholder="Nama dan gelar" maxlength="60" value="<?php echo $_POST['nama'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nama;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Gender</label>
                                                <div class="col-lg-5">
                                                    <div class="radio">
                                                    <?php echo'
                                                        <label>
                                                            <input type="radio" name="gender" value="L" '.$check1.'/> Laki
                                                        </label>

                                                        <label>
                                                            <input type="radio" name="gender" value="P" '.$check2.'/> Perempuan
                                                        </label> ';?>
                                                    </div>

                                                </div>
                                            </div>
                                             <?php echo $er_gender;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tempat Lahir</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="tempat" id="tempat" placeholder="Tempat Lahir" maxlength="50" value="<?php echo $_POST['tempat'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_tempat;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tanggal Lahir</label>
                                                <div class="col-lg-5 date">
                                                    <div class="input-group input-append date" id="datePicker">
                                                        <input type="text" class="form-control" name="tanggal" id="tanggal" placeholder="Tanggal Lahir" value="<?php echo $_POST['tanggal'];?>"/>
                                                        <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span>
                                                    </div>
                                                </div>
                                            </div>
                                            <?php echo $er_tgllahir;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Email</label>
                                                <div class="col-lg-5">
                                                    <input type="email" class="form-control" name="email" id="email" placeholder="Email" maxlength="60" value="<?php echo $_POST['email'];?>" />
                                                </div>
                                            </div>
                                            <?php echo $er_email;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">No. Telp</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="telp" id="telp" placeholder="No Telp" maxlength="15" value="<?php echo $_POST['telp'];?>" />
                                                </div>
                                            </div>
                                            <?php echo $er_telp;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Alamat Dusun / Nama Jalan</label>
                                                <div class="col-lg-5">
                                                    <textarea class="form-control" name="alamat" id="alamat" placeholder="Nama Dusun / Nama Jalan" rows="4"><?php echo $_POST['alamat'];?></textarea>
                                                </div>
                                            </div>
                                            <?php echo $er_alamat;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Pendidikan</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="pend" id="pend" placeholder="Pendidikan" maxlength="100" value="<?php echo $_POST['pend'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_pend;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Jabatan</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="jabatan" id="jabatan" placeholder="Jabatan" maxlength="100" value="<?php echo $_POST['jabatan'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_jabatan;?>

                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Status Menikah</label>
                                                <div class="col-lg-4">
                                                    <select class="form-control" name="menikah">
                                                        <option value="">-- Pilih --</option>
                                                        <?php echo '
                                                        <option value="Ya" '.$ya.'>Ya</option>
                                                        <option value="Belum" '.$no.'>Belum</option>
                                                        ';?>
                                                    </select>
                                                </div>
                                            </div>
                                            <?php echo $er_menikah;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Status Kepegawaian</label>
                                                <div class="col-lg-4">
                                                    <select class="form-control" name="status" id="status">
                                                        <option value="">-- Pilih --</option>
                                                        <?php echo '
                                                        <option value="PNS" '.$pns.'>PNS</option>
                                                        <option value="PNS Diperbantukan" '.$pnsdip.'>PNS Diperbantukan</option>
                                                        <option value="PNS Depag" '.$pnsdep.'>PNS Depag</option>
                                                        <option value="GTY/PTY" '.$gty.'>GTY/PTY</option>
                                                        <option value="GTT/PTT" '.$gtt.'>GTT/PTT</option>
                                                        <option value="Guru Bantu Pusat" '.$gbp.'>Guru Bantu Pusat</option>
                                                        <option value="Guru Bantu Sekolah" '.$gbs.'>Guru Bantu Sekolah</option>
                                                        <option value="Tenaga Honor" '.$th.'>Tenaga Honor</option>
                                                        ';?>
                                                    </select>
                                                </div>
                                            </div>
                                            <?php echo $er_status;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Foto</label>
                                                <div class="col-lg-5">
                                                    <input type="file" class="form-control" name="foto" id="foto" />

                                                </div>
                                            </div>
                                            <?php echo $er_foto;?>
                                            <hr>
                                            <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";

?>

Hasil dari file input_guru.php jika di coba dibrowser seperti ini

input-guru

Bagian 7 : Buat file baru beri nama edit_guru.php simpan di folder ADMINWEB

Isi dari file edit_guru.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>
                            Edit Data Guru & Karyawan
                        </h3>
                        <ol class="breadcrumb">
                            <li>
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li>
                                 <i class="fa fa-list"></i> Data Pokok
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar Guru & Karyawan
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                //ambil data berdasarkan id
                $tampildata=mysqli_query($conect, "select*from tb_guru where nip_guru='$_GET[nip_guru]'");
                $b=mysqli_fetch_array($tampildata);

                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);  //variabel dari name input nama
                $nip=mysqli_real_escape_string($conect, $_POST['nip']);
                $nik=mysqli_real_escape_string($conect, $_POST['nik']);
                $email=mysqli_real_escape_string($conect, $_POST['email']);
                $telp=mysqli_real_escape_string($conect, $_POST['telp']);
                $status=mysqli_real_escape_string($conect, $_POST['status']);
                $pend=mysqli_real_escape_string($conect, $_POST['pend']);
                $jabatan=mysqli_real_escape_string($conect, $_POST['jabatan']);
                $tempat=mysqli_real_escape_string($conect, $_POST['tempat']);
                $tgllahir=mysqli_real_escape_string($conect, $_POST['tanggal']);
                $alamat=mysqli_real_escape_string($conect, $_POST['alamat']);
                $gender=mysqli_real_escape_string($conect, $_POST['gender']);
                $menikah=mysqli_real_escape_string($conect, $_POST['menikah']);
                $pass=mysqli_real_escape_string($conect, $_POST['pass']);

                $foto=$_FILES['foto']['tmp_name'];               //variabel dari temporary foto
                $nama_foto=$_FILES ['foto']['name'];             //variabel dari name input foto
                $type=$_FILES['foto']['type'];                   //variabel dari type foto
                $ukuran=$_FILES['foto']['size'];                 //variabel dari ukuran foto
                $files= strtolower(substr(strrchr($nama_foto,"."),1)); //variabel untuk extensi file

                //jika menekan tombol simpan
                if(isset($_POST['simpan'])){
                if(empty($nip)){
                $er_nip="<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 NIP guru </div>";
                }
                elseif(empty($nik)){
                $er_nik="<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 NIK Guru </div>";
                }
                elseif(empty($nama)){
                $er_nama="<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 Guru </div>";
                }
                elseif(empty($gender)){
                $er_gender="<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 Gender Guru </div>";
                }
                elseif(empty($tempat)){
                $er_tempat="<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 Tempat Lahir</div>";
                }
                elseif(empty($tgllahir)){
                $er_tgllahir="<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 Tanggal Lahir</div>";
                }
                elseif(empty($email)){
                $er_email="<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 Email Guru</div>";
                }
                elseif(empty($telp)){
                $er_telp="<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 No. Telp</div>";
                }
                elseif(empty($alamat)){
                $er_alamat="<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 Alamat Guru</div>";
                }
                elseif(empty($pend)){
                $er_pend="<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 Pendidikan Terakhir</div>";
                }
                elseif(empty($jabatan)){
                $er_jabatan="<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 Jabatan Guru</div>";
                }
                elseif($menikah == ""){
                $er_menikah="<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 status Menikah</div>";
                }
                elseif($status == ""){
                $er_status="<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 status Kepegawaian</div>";
                }
                elseif($pass == ""){
                $er_pass="<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 Password</div>";
                }
                else{
                if(empty($foto)){
                $save=mysqli_query($conect, "UPDATE tb_guru set pass_guru='$pass', alamat_guru='$alamat', gender_guru='$gender', nama_guru='$nama', email_guru='$email', pend_guru='$pend', jabatan_guru='$jabatan', telp_guru='$telp', tempatlahir_guru='$tempat', tgllahir_guru='$tgllahir', status_menikah='$menikah', status_guru='$status', nik_guru='$nik' where nip_guru='$_GET[nip_guru]'");
                if($save){   //save
                echo " <script>alert('Data Berhasil Diubah');document.location='guru.php'</script>";
                }
                else{    //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> Perubahan Gagal</div>";
                }
                }
                else{ //jika foto ikut diubah maka
                if($files !="jpg" && $files !="png"){ //jika foto tidak berekstensi .jpg atau .png
                $er_foto="<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> Format Gambar yang diizinkan hanya .jpg dan .png</div>";
                }
                elseif($ukuran > 2000000){   //jika ukuran lebih besar dari 2MB
                $er_foto="<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> Maksimal ukuran gambar 2MB </div>";
                }
                elseif(strlen($nama_foto) > 100){  //jika jumlah karakter nama foto lebih dari 100 karakter
                $er_foto="<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> Nama File Gambar Mak 100 karakter</div>";
                }
                else{ //jika semua field terpenuhi maka simpan gambar ke folder dan simpan data ke tabel

                unlink('../assets/images/guru/'.$lama); //hapus foto lama di folder
                move_uploaded_file($foto,"../assets/images/guru/$nama_foto");  //upload foto baru
                //simpan ke tabel database
                $save=mysqli_query($conect, "UPDATE tb_guru set pass_guru='$pass', alamat_guru='$alamat', gender_guru='$gender', nama_guru='$nama', email_guru='$email', foto_guru='$nama_foto', pend_guru='$pend', jabatan_guru='$jabatan', telp_guru='$telp', tempatlahir_guru='$tempat', tgllahir_guru='$tgllahir', status_menikah='$menikah', status_guru='$status', nik_guru='$nik' where nip_guru='$_GET[nip_guru]'");
                if($save){ //jika simpan berhasil
                echo "<script>alert('Data Berhasil Diubah');document.location='guru.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> Perubahan gagal, ulangi lagi</div>";
                }
                }
                }

                }
                }

                if($b['gender_guru'] == "L"){
                    $check1='checked';
                }elseif($b['gender_guru'] == "P"){
                    $check2='checked';
                }

                if($b['status_menikah'] == "Ya"){
                    $ya='selected';
                }elseif($b['status_menikah'] == "Belum"){
                    $no='selected';
                }

                if($b['status_guru'] == "PNS"){
                    $pns='selected';
                }elseif($b['status_guru'] == "PNS Diperbantukan"){
                    $pnsdip='selected';
                }elseif($b['status_guru'] == "PNS Depag"){
                    $pnsdep='selected';
                }elseif($b['status_guru'] == "GTY/PTY"){
                    $gty='selected';
                }elseif($b['status_guru'] == "GTT/PTT"){
                    $gtt='selected';
                }elseif($b['status_guru'] == "Guru Bantu Pusat"){
                    $gbp='selected';
                }elseif($b['status_guru'] == "Guru Bantu Sekolah"){
                    $gbs='selected';
                }elseif($b['status_guru'] == "Tenaga Honor"){
                    $th='selected';
                }

                ?>
                <!-- .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="guru.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">
                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">NIP</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nip" id="nip" placeholder="NIP" maxlength="30" value="<?php echo $b['nip_guru'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nip;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">NIK</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nik" id="nik" placeholder="NIK" maxlength="30" value="<?php echo $b['nik_guru'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nik;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Nama dan Gelar</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="nama" id="nama" placeholder="Nama dan gelar" maxlength="60" value="<?php echo $b['nama_guru'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_nama;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Gender</label>
                                                <div class="col-lg-5">
                                                    <div class="radio">
                                                    <?php echo'
                                                        <label>
                                                            <input type="radio" name="gender" value="L" '.$check1.'/> Laki
                                                        </label>

                                                        <label>
                                                            <input type="radio" name="gender" value="P" '.$check2.'/> Perempuan
                                                        </label> ';?>
                                                    </div>

                                                </div>
                                            </div>
                                             <?php echo $er_gender;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tempat Lahir</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="tempat" id="tempat" placeholder="Tempat Lahir" maxlength="50" value="<?php echo $b['tempatlahir_guru'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_tempat;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Tanggal Lahir</label>
                                                <div class="col-lg-5 date">
                                                    <div class="input-group input-append date" id="datePicker">
                                                        <input type="text" class="form-control" name="tanggal" id="tanggal" placeholder="Tanggal Lahir" value="<?php echo $b['tgllahir_guru'];?>"/>
                                                        <span class="input-group-addon add-on"><span class="glyphicon glyphicon-calendar"></span></span>
                                                    </div>
                                                </div>
                                            </div>
                                            <?php echo $er_tgllahir;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Email</label>
                                                <div class="col-lg-5">
                                                    <input type="email" class="form-control" name="email" id="email" placeholder="Email" maxlength="60" value="<?php echo $b['email_guru'];?>" />
                                                </div>
                                            </div>
                                            <?php echo $er_email;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">No. Telp</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="telp" id="telp" placeholder="No Telp" maxlength="15" value="<?php echo $b['telp_guru'];?>" />
                                                </div>
                                            </div>
                                            <?php echo $er_telp;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Alamat Dusun / Nama Jalan</label>
                                                <div class="col-lg-5">
                                                    <textarea class="form-control" name="alamat" id="alamat" placeholder="Nama Dusun / Nama Jalan" rows="4"><?php echo $b['alamat_guru'];?></textarea>
                                                </div>
                                            </div>
                                            <?php echo $er_alamat;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Pendidikan</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="pend" id="pend" placeholder="Pendidikan" maxlength="100" value="<?php echo $b['pend_guru'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_pend;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Jabatan</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="jabatan" id="jabatan" placeholder="Jabatan" maxlength="100" value="<?php echo $b['jabatan_guru'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_jabatan;?>

                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Status Menikah</label>
                                                <div class="col-lg-4">
                                                    <select class="form-control" name="menikah">
                                                        <option value="">-- Pilih --</option>
                                                        <?php echo '
                                                        <option value="Ya" '.$ya.'>Ya</option>
                                                        <option value="Belum" '.$no.'>Belum</option>
                                                        ';?>
                                                    </select>
                                                </div>
                                            </div>
                                            <?php echo $er_menikah;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Status Kepegawaian</label>
                                                <div class="col-lg-4">
                                                    <select class="form-control" name="status" id="status">
                                                        <option value="">-- Pilih --</option>
                                                        <?php echo '
                                                        <option value="PNS" '.$pns.'>PNS</option>
                                                        <option value="PNS Diperbantukan" '.$pnsdip.'>PNS Diperbantukan</option>
                                                        <option value="PNS Depag" '.$pnsdep.'>PNS Depag</option>
                                                        <option value="GTY/PTY" '.$gty.'>GTY/PTY</option>
                                                        <option value="GTT/PTT" '.$gtt.'>GTT/PTT</option>
                                                        <option value="Guru Bantu Pusat" '.$gbp.'>Guru Bantu Pusat</option>
                                                        <option value="Guru Bantu Sekolah" '.$gbs.'>Guru Bantu Sekolah</option>
                                                        <option value="Tenaga Honor" '.$th.'>Tenaga Honor</option>
                                                        ';?>
                                                    </select>
                                                </div>
                                            </div>
                                            <?php echo $er_status;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Foto</label>
                                                <div class="col-lg-5">
                                                    <input type="file" class="form-control" name="foto" id="foto" />

                                                </div>
                                            </div>
                                            <?php echo $er_foto;?>
                                            <div class="form-group row">
                                                <label class="col-lg-3 control-label">Password</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="pass" id="pass" placeholder="Password" maxlength="30" value="<?php echo $b['pass_guru'];?>"/>
                                                </div>
                                            </div>
                                            <?php echo $er_pass;?>

                                            <hr>
                                            <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";

?>

Hasil dari file edit_guru.php jika di coba dibrowser seperti ini

edit-guru

Bagian 8 : Buat file baru beri nama hapus_guru.php simpan di folder ADMINWEB

Isi dari file hapus_guru.php seperti ini

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

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

if(isset($id)){ //jika ada id
//ambil data di tabel berdasarkan id
$data=mysqli_fetch_array(mysqli_query($conect, "select * from tb_guru where nip_guru='$id'"));

//hapus gambar di folder
unlink("../assets/images/guru/$data[foto_guru]");

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

}
?>

Hasil dari file hapus_guru.php jika di coba dibrowser seperti ini

hapus-guru

Bagian 6 : Buat file baru beri nama cari_guru.php simpan di folder ADMINWEB

Isi dari file cari_guru.php seperti ini

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

//pemanggilan file navbar
include "setting_navbar.php";
?>
<style type="text/css">
th{
    min-width:70px;
}
</style>
        <div id="page-wrapper">

            <div class="container-fluid">
                <!-- .row -->
                <!-- Page Heading  breadcumb-->
                <div class="row">
                    <div class="col-lg-12">
                        <h3>
                            Daftar Guru & Karyawan
                        </h3>
                        <ol class="breadcrumb">
                            <li>
                                <i class="fa fa-dashboard"></i> Home
                            </li>
                            <li>
                                 <i class="fa fa-list"></i> Data Pokok
                            </li>
                            <li class="active">
                                <i class="fa fa-list"></i> Daftar Guru & Karyawan
                            </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">
                            <div class="col-lg-6">
                            <a href="input_guru.php" title="Input data"><button name="input" class="btn btn-primary"><i class="fa fa-plus-square-o fa-fw"></i> Input</button></a>
                            </div>
                            <div class="col-lg-6">
                            <!-- form pencarian produk -->
                            <form action="cari_guru.php" method="get" class="form-inline text-right">
                            <input type="text" class="form-control" name="qw" placeholder="Cari Guru" required>
                            <button type="submit" class="btn btn-primary">Cari</button>
                            </form>
                            <!-- form pencarian produk -->
                            </div>
                            <div style="clear:both;"></div>
                            </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>NIP</th>
                                                <th>Nama Lengkap</th>
                                                <th>Tempat Lahir</th>
                                                <th>Tanggal Lahir</th>
                                                <th>L/P</th>
                                                <th>Alamat</th>
                                                <th>Telp</th>
                                                <th>Email</th>
                                                <th>NIK</th>
                                                <th>Menikah</th>
                                                <th>Pendidikan</th>
                                                <th>Jabatan</th>
                                                <th>Status</th>
                                                <th>Foto</th>
                                                <th>Action</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        $pg = isset( $_GET['pg'] ) ? $_GET['pg'] : "";
                                        $batas = 25; /*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_guru where nama_guru LIKE '%$_GET[qw]%' OR nip_guru LIKE '%$_GET[qw]%' order by nip_guru desc 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="16">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['nip_guru'];?></td>
                                            <td><?php echo $a['nama_guru'];?></td>
                                            <td><?php echo $a['tempatlahir_guru'];?></td>
                                            <td><?php echo tgl_indo($a['tgllahir_guru']);?></td>
                                            <td><?php echo $a['gender_guru'];?></td>
                                            <td><?php echo $a['alamat_guru'];?></td>
                                            <td><?php echo $a['telp_guru'];?></td>
                                            <td><?php echo $a['email_guru'];?></td>
                                            <td><?php echo $a['nik_guru'];?></td>
                                            <td><?php echo $a['status_menikah'];?></td>
                                            <td><?php echo $a['pend_guru'];?></td>
                                            <td><?php echo $a['jabatan_guru'];?></td>
                                            <td><?php echo $a['status_guru'];?></td>

                                            <td><img src="<?php echo $hostname;?>/assets/images/guru/<?php echo $a['foto_guru'];?>" class="img-thumbnail" style="width:60px; height:60px;"></td>
                                            <td><a href="hapus_guru.php?nip_guru=<?php echo $a['nip_guru'];?>" 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_guru.php?nip_guru=<?php echo $a['nip_guru'];?>" 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_guru order by nip_guru 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";

?>

 

Silahkan anda coba semua file yang sudah dibuat.

Thanks.

 

 

 

 

Develindo Web | Tutorial Pemrograman Website