[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
xampp182
/
htdocs
/
wablast
/
[
Home
]
File: kontak.inc.php
<?php $id = ""; $nama = ""; $hp = ""; $email = ""; $buton = "Simpan"; $u_pswd = "-"; $u_name = "-"; $hp = "-"; $ktp = "-"; $kota_asal = ""; $alamat = ""; $email = ""; $nama = ""; if(isset($_GET["deleteID"])) { $sql = "delete from kontak where id = ".$_GET["deleteID"]; if (mysqli_query($conn, $sql)) { echo "<script>window.alert('Data Sudah Terhapus');</script>"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } if(isset($_GET["editID"])) { $sql = "SELECT * FROM kontak where id = ".$_GET["editID"]." order by id desc"; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $id = $row['id']; $nama = $row['nama']; $hp = $row['hp']; $email = $row['email']; $buton = "Koreksi"; } } } if(isset($_GET["setaktif"])) { $setz = mysqli_query($conn, "update kontak set aktif = 0"); $sql = "update kontak set aktif = 1 where id = ".$_GET["setaktif"]; if (mysqli_query($conn, $sql)) { echo "<scrnamat>window.alert('Set Aktif');</scrnamat>"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } if(isset($_POST["Simpan"]) || isset($_POST["Koreksi"])) { if(isset($_POST["hp"])) $hp = $_POST["hp"]; if(isset($_POST["grup"])) $grup = $_POST["grup"]; if(isset($_POST["nama"])) $nama = $_POST["nama"]; if(isset($_POST["id"])) $id = $_POST["id"]; $tbField[0] = "nama"; $tbField[1] = "hp"; $tbField[2] = "grup"; $tbIsi[0] = "'".$nama."'"; $tbIsi[1] = "'".$hp."'"; $tbIsi[2] = "'".$grup."'"; if(isset($_POST["Simpan"])) { $nmField = compile_array($tbField); $isiField = compile_array($tbIsi); $sql = "insert into kontak (".$nmField.") values (".$isiField.")"; $notif = $ssm; } if(isset($_POST["Koreksi"])) { $compileSet = compile_array2($tbField,$tbIsi); $sql = "update kontak set ".$compileSet." where id = ".$id; $notif = $sum; } if (mysqli_query($conn, $sql)) { echo "<script>window.alert('".$notif."');</script>"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } } ?> <div class="container-fluid"> <div class="card shadow mb-4"> <div class="card-header py-3"> <h6 class="m-0 font-weight-bold text-primary">Entry Data Kontak</h6> </div> <div class="card-body"> <form class="user" action="dashboard.php?kontak" accept-charset="utf-8" method="post"> <div class="col m6"> <div class="row"> <div class="input-field col m6 s12"> <table border="0" width="100%" cellspacing="1" cellpadding="1"> <tr> <td width="30%">Nama</td> <td width="70%"> <input value="<?php echo $id;?>" name="id" type="hidden"> <input value="<?php echo $nama;?>" name="nama" type="text" class="form-control" id="exampleFirstName" placeholder="Nama"> </td> </tr> <tr> <td>No Handphone</td> <td> <input value="<?php echo $hp;?>" name="hp" type="number" class="form-control" id="hp" placeholder=""> </td> </tr> <tr> <td>Grup</td> <td> <select name="grup" class="form-control"> <option value="0"> - Pilih - </option> <?php $sql = "SELECT * FROM grup order by id asc"; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { ?> <option value="<?php echo $row["id"];?>"> <?php echo $row["nama"];?> </option> <?php }} ?> </select> </td> </tr> <tr> <td> </td> <td> <div class="form-group row"> <div class="col-sm-3 mb-3 mb-sm-0"> <button name="<?php echo $buton;?>" type="submit" class="btn btn-primary btn-block"><?php echo $buton;?></button> </div> <div class="col-sm-3"> <button name="Cancel" type="submit" class="btn btn-primary btn-block">Cancel</button> </div> </div> </td> </tr> </table> </div> </div> </div> </div> </div> </div> </form> <div class="container-fluid"> <!-- Page Heading --> <!-- DataTales Example --> <div class="card shadow mb-4"> <div class="card-header py-3"> <h6 class="m-0 font-weight-bold text-primary">DataTables</h6> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"> <thead> <tr> <th>Aksi</th> <th>Nama</th> <th>HP</th> <th>Grup</th> </tr> </thead> <tfoot> <tr> <th>Aksi</th> <th>Nama</th> <th>HP</th> <th>Grup</th> </tr> </tfoot> <tbody> <?php $sql = "SELECT a.*,b.nama as grupwa FROM kontak a left join grup b on a.grup = b.id order by id desc"; $result = mysqli_query($conn, $sql); if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { ?> <tr> <td width="10%"> <a class="btn btn-primary btn-danger" href="dashboard.php?kontak&deleteID=<?php echo $row['id'];?>"><i class="fas fa-trash"></i></a> <a class="btn btn-primary btn-warning" href="dashboard.php?kontak&editID=<?php echo $row['id'];?>"><i class="fas fa-edit"></i></a> </td> <td width="35%"><?php echo $row['nama'];?></td> <td width="25%"><?php echo $row['hp'];?></td> <td width="35%"><?php echo $row['grupwa'];?></td> </tr> <?php } } ?> </tbody> </table> </div> </div> </div> </div>