Online Course

AN02 - Membuat Pengaturan Akun Admin Di Halaman Admin

Tutorial Membuat Pengaturan Akun Admin Di Halaman Admin

Pengaturan akun admin berfungsi untuk mengatur/mengelola data akun yang dapat login ke sistem admin. Jadi tidak perlu mengedit melalui phpmyadmin.

Bagian 1 : Buat file admin.php simpan di folder ADMINWEB

Isi dari file admin.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 Admin
                            <?php
                            //jika admin memiliki level Super Admin Maka dapat menambahkan data baru, namu jika bukan super admin tidak dapat menginput admin baru
                            if($admin['level_admin'] =='Super Admin'){
                             ?>
                                <a href="input_admin.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>
                            <?php
                            }
                            ?>
                        </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 Admin
                            </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 Akun Admin
                            </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>Nama Admin</th>
                                                <th>Email</th>
                                                <th>Level</th>
                                                <th>Action</th>

                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php
                                        //jika admin memiliki level Super Admin Maka dapat mengelola semua akun dan menambahkan data baru
                                        if($admin['level_admin'] =='Super Admin'){

                                        $ambildata=mysqli_query($conect, "select*from tb_admin order by id_admin");
                                        $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_admin'];?></td>
                                            <td><?php echo $a['email_admin'];?></td>
                                            <td><?php echo $a['level_admin'];?></td>
                                            <td><a href="hapus_admin.php?id_admin=<?php echo $a['id_admin'];?>" 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_admin.php?id_admin=<?php echo $a['id_admin'];?>" 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
                                            }
                                        }
                                        }else{
                                            //jika admin hanya level admin maka hanya dapat mengedit akunnya sendiri
                                        $ambildata=mysqli_query($conect, "select*from tb_admin where id_admin='$admin[id_admin]'");
                                        $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_admin'];?></td>
                                            <td><?php echo $a['email_admin'];?></td>
                                            <td><?php echo $a['level_admin'];?></td>
                                            <td><a href="edit_admin.php?id_admin=<?php echo $a['id_admin'];?>" 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>
                            <!-- /.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";

?>

Jalnkan pada halaman admin dengan klik Pengaturan -> Klik Akun admin maka akan muncul halaman seperti ini

admin

Data yang tertera merupakan data yang terdapat di tb_admin di database anda

 

Bagian 2 : Membuat file input_admin.php simpan difolder ADMINWEB

Isi dari file input_admin.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 Admin
                        </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 Admin
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);   //variabel nama
                $pass=mysqli_real_escape_string($conect, $_POST['pass']);   //variabel password
                $pass2=mysqli_real_escape_string($conect, $_POST['pass2']); //variabel ulangi password
                $level=mysqli_real_escape_string($conect, $_POST['level']);    //variabel level admin
                $email=mysqli_real_escape_string($conect, $_POST['email']);     //variabel email
                $polaemail ="^.+@.+..+$";                           //pola email
                $validasi= strtolower(substr(strrchr($email,"@"),1));         //validasi email
                $pass3=md5($pass);    //password di enkripsi ke md5

                if(isset($_POST['simpan'])){
                    if(empty($nama)){  //jika 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 Admin !</div>";
                    }
                    elseif(empty($email)){     //jika email 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 Admin !</div>";
                    }
                    //jika email tidak bukan berakhiran @yahoo, gmail, atau bsi
                    elseif($validasi !="yahoo.com" && $validasi !="yahoo.co.id" && $validasi !="gmail.com" && $validasi !="bsi.ac.id"){
                        $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 Dengan Format yahoo atau gmail !</div>";
                        }
                    elseif($level ==""){     //jika level admin kosong
                        $er_level="<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 Level Admin !</div>";
                    }
                    elseif(empty($pass)){  //jika password kosong
                        $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 Admin !</div>";
                    }
                    elseif(strlen ($pass)< 8){   //jika password kurang dari 8 karakter
                        $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 Admin  Min. 8 Karakter!</div>";
                    }
                    elseif(strlen ($pass)> 15){  //jika password lebih dari 15 karakter
                        $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 Admin  Max. 15 Karakter!</div>";
                        }
                    elseif(empty($pass2)){  //jika ulangi password kosong
                        $er_pass2="<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> Ulangi Password Admin !</div>";
                    }
                    elseif($pass != $pass2){     //jika password dan ulangi password salah
                        $er_pass2="<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> Ulangi Password Admin Dengan Benar !</div>";
                        }

                    else{   //jika semua field terisis, maka cek email apakah sudah terdaftar atau belum di tb_admin
                        $cek_email=mysqli_query($conect, "SELECT*FROM tb_admin where email_admin='$email'");
                        $email_ada=mysqli_num_rows($cek_email);
                        if($email_ada > 0){   //jika email sudah terdaftar
                            $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> Email Sudah Terdaftar !</div>";
                        }else{
                            //jika email belum terdaftar maka menyimpan data ke tb_admin
                            $save=mysqli_query($conect, "INSERT INTO tb_admin (id_admin,nama_admin,email_admin,pass_admin,level_admin)values('','$nama','$email','$pass3','$level')");
                            if($save){
                                echo "<script>alert('Data Admin Baru Berhasil DItambahkan');document.location='admin.php'</script>";
                            }else{
                                $error="<div class='alert alert-danger alert-dismissable'>
                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                                <i class='fa fa-info-circle'></i> Gagal Menyimpan !</div>";
                            }
                        }
                    }
                }
                //jika POST level sama dengan Admin maka variabel $adm di select atau dipilih
                if($_POST['level']=="Admin"){
                $adm="selected";
                }
                //jika POST level sama dengan Super Admin maka variabel $super di select atau dipilih
                elseif($_POST['level']=="Super Admin"){
                $super="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="admin.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">Nama Admin</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input type="text" class="form-control" placeholder="Nama Admin" name="nama" value="<?php echo $_POST['nama'];?>" maxlength="40">
                                </div>
                            </div>
                            <?php echo $er_nama;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Email Admin</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input  type="email" class="form-control" placeholder="Email Admin" name="email" value="<?php echo $_POST['email'];?>" maxlength="100">
                                </div>
                            </div>
                            <?php echo $er_email;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Level Admin</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <select class="form-control" name="level">
                                    <?php echo "
                                    <option value=''>Pilih</option>
                                    <option value='Admin' $adm>Admin</option>
                                    <option value='Super Admin' $super>Super Admin</option>
                                    ";?>
                                </select>
                                </div>
                            </div>
                            <?php echo $er_level;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Password</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input  type="password" class="form-control" placeholder="Password" name="pass" value="<?php echo $_POST['pass'];?>" maxlength="15">
                                </div>
                            </div>
                            <?php echo $er_pass;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Ulangi Password</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input  type="password" class="form-control" placeholder="Ulangi Password" name="pass2" value="<?php echo $_POST['pass2'];?>" maxlength="15">
                                </div>
                            </div>
                            <?php echo $er_pass2;?>


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

?>

Coba jalankan dengan klik tombol input pada halaman daftar admin, maka akan muncul form seperti ini

input-admin

Silahkan anda coba untuk mengisi data admi baru dan simpan, jika berhasil maka data akan tersimpan di tb_admin.

 

Bagian ke 3 : Membuat file edit_admin.php simpan di folder ADMINWEB

Isi dari file edit_admin.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 Data Admin
                        </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 admin
                            </li>
                        </ol>
                    </div>
                </div>
                <!-- /.row -->

                <?php
                $tampildata=mysqli_query($conect, "select*from tb_admin where id_admin='$_GET[id_admin]'");
                $b=mysqli_fetch_array($tampildata);



                //variabel setiap input di form
                $nama=mysqli_real_escape_string($conect, $_POST['nama']);   //variabel nama
                $pass=mysqli_real_escape_string($conect, $_POST['pass']);   //variabel password
                $pass2=mysqli_real_escape_string($conect, $_POST['pass2']); //variabel ulangi password
                $email=mysqli_real_escape_string($conect, $_POST['email']);     //variabel email
                $polaemail ="^.+@.+..+$";                           //pola email
                $validasi= strtolower(substr(strrchr($email,"@"),1));         //validasi email
                $pass3=md5($pass);    //password di enkripsi ke md5

                if(isset($_POST['simpan'])){
                    if(empty($nama)){  //jika 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 Admin !</div>";
                    }
                    elseif(empty($email)){     //jika email 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 Admin !</div>";
                    }
                    elseif(!eregi($polaemail, $email)){  //jika email tidak sesuai pola 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 Dengan Format Email !</div>";
                    }
                    //jika email tidak bukan berakhiran @yahoo, gmail, atau bsi
                    elseif($validasi !="yahoo.com" && $validasi !="yahoo.co.id" && $validasi !="gmail.com" && $validasi !="bsi.ac.id"){
                        $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 Dengan Format yahoo atau gmail !</div>";
                        }
                    elseif(empty($pass)){  //jika password kosong
                        $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 Admin !</div>";
                    }
                    elseif(strlen ($pass)< 8){   //jika password kurang dari 8 karakter
                        $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 Admin  Min. 8 Karakter!</div>";
                    }
                    elseif(strlen ($pass)> 15){  //jika password lebih dari 15 karakter
                        $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 Admin  Max. 15 Karakter!</div>";
                        }
                    elseif(empty($pass2)){  //jika ulangi password kosong
                        $er_pass2="<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> Ulangi Password Admin !</div>";
                    }
                    elseif($pass != $pass2){     //jika password dan ulangi password salah
                        $er_pass2="<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> Ulangi Password Admin Dengan Benar !</div>";
                        }

                    else{   //jika semua field terisis, maka cek email apakah sudah terdaftar atau belum di tb_admin
                    if($email != $b['email_admin']){ //jika email yang dimasukan berbeda dengan email sebelumnya
                        $cek_email=mysqli_query($conect, "SELECT*FROM tb_admin where email_admin='$email'");
                        $email_ada=mysqli_num_rows($cek_email);
                        if($email_ada > 0){   //jika email sudah terdaftar
                            $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> Email Sudah Terdaftar !</div>";
                        }else{
                            //jika email belum terdaftar maka menyimpan data ke tb_admin
                            $save=mysqli_query($conect, "UPDATE tb_admin set nama_admin='$nama', email_admin='$email', pass_admin='$pass3' where id_admin='$_GET[id_admin]' ");
                            if($save){
                                echo "<script>alert('Data Admin Berhasil DIubah');document.location='admin.php'</script>";
                            }else{
                                $error="<div class='alert alert-danger alert-dismissable'>
                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                                <i class='fa fa-info-circle'></i> Gagal Menyimpan !</div>";
                            }
                        }
                    }else{  //jika email sama dengan sebelumnya
                        $save=mysqli_query($conect, "UPDATE tb_admin set nama_admin='$nama', pass_admin='$pass3' where id_admin='$_GET[id_admin]' ");
                            if($save){
                                echo "<script>alert('Data Admin Berhasil diubah');document.location='admin.php'</script>";
                            }else{
                                $error="<div class='alert alert-danger alert-dismissable'>
                                <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
                                <i class='fa fa-info-circle'></i> Gagal Menyimpan !</div>";
                            }
                        }

                    }
                }

                if($_POST['level']=="Admin"){
                $adm="selected";
                }
                elseif($_POST['level']=="Super Admin"){
                $super="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="admin.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">Nama Admin</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input  type="text" class="form-control" placeholder="Nama Admin" name="nama" value="<?php echo $b['nama_admin'];?>" maxlength="40">
                                </div>
                            </div>
                            <?php echo $er_nama;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Email Admin</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input  type="text" class="form-control" placeholder="Email Admin" name="email" value="<?php echo $b['email_admin'];?>" maxlength="100">
                                </div>
                            </div>
                            <?php echo $er_email;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Password</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input  type="password" class="form-control" placeholder="Password" name="pass" value="<?php echo $_POST['pass'];?>" maxlength="15">
                                </div>
                            </div>
                            <?php echo $er_pass;?>
                            <div class="form-group row">
                                <label class="col-lg-2 col-md-3 col-sm-3 col-xs-12">Ulangi Password</label>
                                <div class="col-lg-8 col-md-7 col-sm-7 col-xs-12">
                                <input  type="password" class="form-control" placeholder="Ulangi Password" name="pass2" value="<?php echo $_POST['pass2'];?>" maxlength="15">
                                </div>
                            </div>
                            <?php echo $er_pass2;?>


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

?>

Silahkan anda coba dengan klik tombol edit pada salh satu data admin yang ada, maka tampilannya akan seperti ini

edit-admin

Coba anda edit apakah data berhasil berubah atau tidak.

 

Bagian Ke 4 : Buat file hapus_admin.php

Isi file hapus_admin.php seperti ini

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

$id=$_GET['id_admin'];
$cekadmin=mysqli_fetch_array(mysqli_query($conect, "select*from tb_admin where id_admin='$id'"));
if($cekadmin['level_admin']=='Super Admin'){
      echo"<script>alert('Perlu diperhatikan, Akun anda bersifat Super Admin dan tidak bisa di hapus');document.location='admin.php'</script>";
}
else{
$yes=mysqli_query($conect, "delete from tb_admin where id_admin='$id'");
if($yes){
    echo"<script>alert('Data Berhasil di Hapus');document.location='admin.php'</script>";
}
else{
    echo"<script>alert('Error Bos !!');document.location='admin.php'</script>";
}
}
?>

Coba dengan klik hapus pada daftar admin, maka data admin akan terhapus.

 

Thanks.

Develindo Web | Tutorial Pemrograman Website