-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle_delete.php
More file actions
36 lines (30 loc) · 799 Bytes
/
single_delete.php
File metadata and controls
36 lines (30 loc) · 799 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
32
33
34
35
36
<?php
// Database connection
$username = "root";
$password = "";
$database = "mydatabase";
// Create connection
$mysqli = new mysqli("localhost", $username, $password, $database);
// Check connection
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
echo "Connected successfully";
?>
<?php
if (isset($_GET['deleteid'])) {
$id = $_GET['deleteid'];
// SQL query to delete the record
$sql = "DELETE FROM saved WHERE thumbnail = '$id'";
$run = mysqli_query($mysqli, $sql);
if ($run) {
echo "<h1>Data Deleted</h1>";
header("Location: index.php");
exit();
} else {
echo "<h1>Data not Deleted</h1>";
}
}
// Close the database connection
$mysqli->close();
?>