-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.php
66 lines (64 loc) · 1.49 KB
/
list.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Lost</title>
</head>
<body>
<?php
session_start();
if($_SESSION['username'] == 'username') {
include "connect.php";
print("<html>");
$conn = connect_db();
$sql = "SELECT * FROM Addresses";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo $row["id"] . " ";
echo $row["name"] . " ";
echo $row["street_address"] . " ";
echo $row["zip"] . " ";
echo $row["city"] . " ";
echo $row["state"] . " ";
echo $row["country"] . " ";
echo "<a href=\"delete.php?id=" . $row["id"] . "\">DELETE</a>";
print("<br>");
}
} else {
echo "0 results";
}
print("<br><br>");
print("Insert new");
print("<form action=\"save.php\" method=\"post\">");
print("<br>");
print("Name: ");
print("<input type=\"text\" name=\"name\">");
print("<br>");
print("Street address: ");
print("<input type=\"text\" name=\"street_address\">");
print("<br>");
print("ZIP: ");
print("<input type=\"text\" name=\"zip\">");
print("<br>");
print("City: ");
print("<input type=\"text\" name=\"city\">");
print("<br>");
print("State: ");
print("<input type=\"text\" name=\"state\">");
print("<br>");
print("Country: ");
print("<input type=\"text\" name=\"country\">");
print("<br>");
print("");
print("<input type=\"submit\" name=\"submit\" value=\"Save\" >");
print("</form>");
print("</html>");
mysqli_close($conn);
} else {
print("No access.");
}
?>
</body>
</html>