-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdelete.php
More file actions
31 lines (26 loc) · 897 Bytes
/
Copy pathdelete.php
File metadata and controls
31 lines (26 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
include 'config.php';
if (isset($_GET['id'])) {
$id = $_GET['id'];
$getId = mysqli_query($koneksi, "SELECT * FROM tbl_rdm WHERE id ='$id'");
$row = mysqli_fetch_assoc($getId);
$namaFile = $row['nama'];
if ($getId) {
$dirPath = dirname(__FILE__) . "/assets/uploads/" . $namaFile;
if (file_exists($dirPath)) {
unlink($dirPath);
$getIdDB = $row['id'];
$delete = "DELETE FROM tbl_rdm WHERE id ='$getIdDB'";
$result = mysqli_query($koneksi, $delete);
echo "<script>
alert('Gambar berhasil dihapus!');
document.location.href = 'index.php';
</script>";
} else {
echo "<script>
alert('Gambar gagal dihapus!');
document.location.href = 'index.php';
</script>";
}
}
}