-
Notifications
You must be signed in to change notification settings - Fork 0
/
deletemember.php
82 lines (65 loc) · 1.96 KB
/
deletemember.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
76
77
78
79
80
81
82
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "gym";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT mid, firstname, lastname, city, email, role FROM member join login on login.LoginId = member.loginid ";
$result = $conn->query($sql);
if ($result->num_rows > 0 && $result->num_rows != 0) {
echo "<table><tr><th>ID</th><th>Name</th><th>lastname</th><th>city</th><th>email</th><th>role</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["mid"]. "</td><td>" . $row["firstname"]. "</td><td>" . $row["lastname"]. "</td><td>". $row["city"]. "</td><td>" . $row["email"]. "</td><td>" . $row["role"]. "</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>
<form method="post" action="deletemember.php" > ID:
<input name="id" type="text" />
<input name="submit" type="submit" value="delete record" onClick="window.location.reload()"/> </form>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "gym";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$id = isset($POST['id']);
// sql to delete a record
$sql = "DELETE FROM member WHERE mid = '$_POST[id]'";
if ($conn->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $conn->error;
}
$conn->close();
?>
Hello there!
Click here to clean <a href = "logout.php" tite = "Logout">Session.</a>
<input type="button" value="back" onclick="window.location.href='admin.php'">
</body>
</html>