-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.php
145 lines (120 loc) · 3.95 KB
/
cart.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
session_start();
if (!isset($_SESSION['loggedin'])) {
echo '<script>alert("You must sign in as an admin!")</script>';
header("refresh:0.1; url=sign_in.php");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css" type="text/css">
<title>Index</title>
<style>
table, th{
border: 1px solid black;
margin-left: 10%;
}
footer{
position: relative;
width: 100%;
background-color: rgb(172, 172, 172);
}
body{
font-size: 18px;
background-color: #e0f3ff;
}
input[type = "submit"]{
font-size: large;
background-color: #4CAF50;
border: none;
color: white;
width: 120px;
height: 40px;
text-decoration: none;
margin: 10px 8px;
cursor: pointer;
}
input[type = "text"],[type = "email"]{
border-radius: 2px;
border-color: black;
border: 1px solid #000000;
background-color: #e4eeff;
color: black;
height: 40px;
font-size: 18px;
text-decoration: none;
margin: 30px 20px;
cursor: pointer;
}
</style>
</head>
<body>
<header>
<div class="container_header">
<img src="https://i.ibb.co/vq7sysz/logo.png" alt="logo" class="logo">
<nav>
<ul>
<li><a href="account.php">Account</a></li>
<li><a href="cart.php">Cart</a></li>
<li><a href="product.php">Products</a></li>
<li><a href="event.php">Event</a></li>
<li><a href="sign_out.php">Sign Out</a>
</li>
</ul>
</nav>
</div>
</header>
<h1 align = "center">Order Information</h1>
<form action = "add_cart.php" method="POST" style="margin-left: 10%;">
<label>E-mail: </label>
<input type = "email" name = "email">
<label>Product: </label>
<input type = "text" name = "product">
<input type = "submit" value = "Add Order" style="margin-left: 5.5%;">
</form>
<?php
$conn = mysqli_connect("localhost", "root", "123456", "nozuonodie");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM `cart`";
$result = $conn->query($sql);
?>
<table style="width:80%">
<tr>
<th width="34%">User Email</th>
<th width="40%">Product</th>
<th width="40%">price</th>
<th></th>
</tr>
<?php
while ($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<th>".$row['email']."</th>";
echo "<th>".$row['product']."</th>";
echo "<th>$".$row['price']."</th>";
echo '<th>
<form action = "delete_cart.php" method="POST">
<input type = "hidden" name = "e" value = "'.$row['email'] .'">
<input type = "hidden" name = "p" value = "'.$row['product'] .'">
<input type = "submit" value = "Delete">
</form>
</th>';
echo "</tr>";
}
?>
</table>
<br><br><br><br><br><br>
<script src="js/script.js"></script>
<br>
<footer>
<img src="images/logo.png" alt="logo">
<p class="copyright">copyright © <script>document.write(new date().getfullyear())</script> all rights reserved</p>
</footer>
</body>
</html>