-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
30 lines (24 loc) · 754 Bytes
/
delete.php
File metadata and controls
30 lines (24 loc) · 754 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
<?php
require_once 'config.php';
// Link aus der GET-Parameter abrufen
if (isset($_GET['link'])) {
$link = $_GET['link'];
// Datei aus der Datenbank und dem Upload-Ordner löschen
$stmt = $conn->prepare("SELECT * FROM files WHERE link = ?");
$stmt->bind_param("s", $link);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows === 1) {
$row = $result->fetch_assoc();
$file = 'data/' . $row['filename'];
unlink($file);
$stmt = $conn->prepare("DELETE FROM files WHERE link = ?");
$stmt->bind_param("s", $link);
$stmt->execute();
}
}
// Zurück zur Admin-Seite weiterleiten
header('Location: admin.php');
// Datenbankverbindung schließen
$conn->close();
?>