<div class="content-wrapper">
    <div class="content-header bg-link bg-link">
        <div class="container-fluid">
            <div class="row mb-2" mb-2>
                <div class="col-sm-6">
                    <h1 class="m-0 text-dark">Update Profil</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item active"><a class="text-dark" href="">Home / </a></li>
                        <li class="breadcrumb-iten active"><a class="text-dark" href=""> Kategori Profil </a></li>
                        <li class="breadcrumb-iten active"><a class="text-dark" href=""> / Update</a></li>
                    </ol>
                </div>
            </div>
        </div>
    </div>

    <?php

    $id = $_GET['idedit'];
    $dataedit = $koneksi->query("SELECT * FROM tbl_kategori WHERE kategori_id ='$id'")->fetch_assoc();
    // var_dump($dataedit);

    ?>

    <div class="card ml-3 mr-3">
        <di class="card-header bg-success">
            <h1>Update Data Admin</h1>
        </di>
        <div class="card-body">

            <form action="" method="POST" enctype="multipart/form-data">
                <div class="form-group">
                    <label>Nama Kategori</label>
                    <input type="text" name="nama" class="form-control" value="<?= $dataedit['kategori_nama']; ?>">
                </div>

                <button type="submit" name="edit" class="btn btn-warning btn-block">Simpan</button>
            </form>

            <?php

            if (isset($_POST['edit'])) {
                $nama     =  $_POST['nama'];
                // echo $nama;
                // exit;
                $edit = $koneksi->query("UPDATE tbl_kategori SET kategori_nama ='$nama' WHERE kategori_id='$id'");

                if ($edit == TRUE) {
                    echo "<script>
                alert ('Data Berhasil Di Simpan');
                window.location= '?page=pages/kategori/view'
                </script>";
                } else {
                    echo "<script>
                alert ('Data Gagal Di Simpan');
                window.location= '?page=pages/kategori/edit'
            </script>";
                }
            }


            ?>


        </div>
    </div>