-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeletePost.php
More file actions
37 lines (34 loc) · 1.11 KB
/
Copy pathdeletePost.php
File metadata and controls
37 lines (34 loc) · 1.11 KB
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
32
33
34
35
36
37
<?php
include_once "database.php";
if (!isset($_POST['submit'])) {
header("Location: home.php");
exit();
}
/**
* Publication Media of the user
*/
$sql = "SELECT * FROM publication WHERE IDPublication=$_POST[DEL]";
$result = mysqli_query($conn, $sql);
if ($row = mysqli_fetch_assoc($result)) {
if ($row['Media'] != null) {
$sql2 = "SELECT * FROM publication INNER JOIN media ON Media = IDMedia WHERE IDPublication=$_POST[DEL] ";
$result2 = mysqli_query($conn, $sql2);
if ($row2 = mysqli_fetch_assoc($result2)) {
$string = __DIR__."/".$row2['Path'];
$string = str_replace("/", "\\", $string);
unlink($string);
}
$sql = "DELETE FROM media WHERE $row[Media] = IDMedia";
$result = mysqli_query($conn, $sql);
if ($result != null) {
echo "delete pubication media successful";
}
}
$sql = "DELETE FROM publication WHERE IDPublication=$_POST[DEL]";
$result = mysqli_query($conn, $sql);
if ($result != null) {
echo "delete publication successful";
}
}
header("Location: home.php");
exit();