-
Notifications
You must be signed in to change notification settings - Fork 1
/
remove_example.php
75 lines (57 loc) · 1.29 KB
/
remove_example.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "genes";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>
<ul id="menu">
<li><a href="#">Home</a></li>
<li><a href="index.php">Search</a></li>
<li><a href="add.php">Upload</a></li>
<li><a href="#">Download</a></li>
<li><a href="#">Contact</a></li>
</ul>
<br /><br />
<?php
if(isset($_GET['id']))
{
$id = $_GET['id'];
print "
<form action = 'remove.php' method = 'POST'>
<input type = 'hidden' name = 'id' value = '$id'>
Are you sure you want to remove record $id?<br />
<input type = 'submit' value = 'yes'>
";
}
if(isset($_POST['id']))
{
$id = $_POST['id'];
$query = "DELETE FROM gene_data WHERE id = $id";
if ($conn->query($query) === TRUE)
{
echo "Record(s) deleted successfully<br />";
}
else
{
echo "Error deleting record: " . $conn->error;
}
}
if(!isset($_GET['id']) && !isset($_POST['id']))
{
die("No record ID provided!");
}
?>
</body>
</html>