Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- date_default_timezone_set("Asia/Jakarta");
- include "config/koneksi.php";
- if(isset($_GET['hapus'])){
- $hapus="delete from gallery where id_foto='$_GET[id]'";
- $war=mysqli_query($con,$hapus);
- if($war){
- echo "<script>alert('Data Terhapus')</script>";
- echo "<script>document.location.href='index.php';</script>";
- }
- }
- // if (isset($_GET['edit'])) {
- // $et = "SELECT * FROM gallery WHERE id_foto = '$_GET[id]'";
- // $it = mysqli_query($con,$et);
- // $edit = mysqli_fetch_array($it);
- // }
- // if(isset($_POST['update'])){
- // $tmp = $_FILES['foto']['tmp_name'];
- // $nama_file = $_FILES['foto']['name'];
- // $folder = "foto";
- // move_uploaded_file($tmp,"$folder/$nama_file");
- // $tgl= date('Y-m-d H:i:s');
- // $pnj="update gallery set judul='$_POST[judul],'foto='$nama_file',tanggal_edit='$tgl' WHERE id_foto = '$_POST[id_foto]'";
- // $ganti = mysqli_query($con,$pnj);
- // if($ganti){
- // echo "<script>alert('Data Teredit')</script>";
- // echo "<script>document.location.href='index.php';</script>";
- // }
- // }
- if(isset($_POST['simpan'])){
- $tmp = $_FILES['foto']['tmp_name'];
- $nama_file = $_FILES['foto']['name'];
- $folder = "foto";
- move_uploaded_file($tmp,"$folder/$nama_file");
- $tgl = date('Y-m-d H:i:s');
- $simpan = mysqli_query($con,"insert into gallery values (null,'$_POST[judul]','$nama_file','$tgl',null)");
- if($simpan){
- echo "<script>alert('Data Tersimpan')</script>";
- echo "<script>document.location.href='index.php';</script>";
- }
- }
- ?>
- <form method="post" enctype="multipart/form-data">
- <table border="2">
- <!-- <tr>
- <td></td>
- <td><td>
- <td><input type="text" name="id_foto" disabled value="<?php echo @$edit[0] ?>"></td>
- </tr> -->
- <tr>
- <td>Judul</td>
- <td>:<td>
- <td><input type="text" name="judul" value="<?php echo @$edit[1] ?>"></td>
- </tr>
- <tr>
- <td>Foto</td>
- <td>:<td>
- <td><input type="file" name="foto" value="<?php echo @$edit[2] ?>"></td>
- </tr>
- <tr>
- <td><input type="submit" name="simpan" value="Simpan"></td>
- <!-- <td></td>
- <td><td>
- <td>
- <?php if(isset($_GET['edit'])){ ?>
- <input type="submit" name="update" value="Update">
- <?php }else{ ?>
- <input type="submit" name="simpan" value="Simpan">
- <?php } ?>
- </td></td></td> -->
- </tr>
- </table>
- </form>
- <table border="1">
- <tr>
- <th>Judul</th>
- <th>Foto</th>
- <th>Tanggal Upload</th>
- <!-- <th>Tanggal Edit</th> -->
- <th>Aksi</th>
- </tr>
- <?php
- $sql="select * from gallery";
- $qry=mysqli_query($con,$sql);
- while($data=mysqli_fetch_array($qry)){
- ?>
- <tr>
- <th><?php echo $data[1] ?></th>
- <th><img src="foto/<?php echo $data[2] ?>" width="150" height="100" /></th>
- <th><?php echo $data[3] ?></th>
- <!-- <th><?php echo $data[4] ?></th> -->
- <th><a href="index.php?hapus&id=<?php echo $data[0] ?>">Hapus</a><!-- ||
- <a href="index.php?edit&id=<?php echo $data[0] ?>">Edit</a></th> -->
- <?php } ?>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement