-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloggedmenu.php
More file actions
224 lines (203 loc) · 7.91 KB
/
loggedmenu.php
File metadata and controls
224 lines (203 loc) · 7.91 KB
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html>
<head>
<!-- https://hdwallsource.com/img/2014/7/solid-color-background-21964-22517-hd-wallpapers.jpg-->
<?php
session_start();
$conn = mysqli_connect('localhost','root','','registration');
echo "<h1>Welcome user</h1>";
?>
<meta name="google-signin-client_id" content="894046296405-2stf1timn6mu271rae78mc2ublsoj5d0.apps.googleusercontent.com">
<title>TraffOlic</title>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Karma">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<!--google sign-in-->
<script src="https://apis.google.com/js/platform.js" async defer></script>
<!--Custom style sheet-->
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" type="text/css" href="menu_images/style.css">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<style>
h3:hover
{color:green;
}
.form{
width: 500px;
height: 500px;
background-color: snow;
margin: 0px auto 0px auto;
padding: 0px 0px 0px 0px
}
.header{
background-color: orangered;
column-rule-style: hidden;
text-align: center;
}
.bg{
background-image: url(form.jpg);
background-repeat: no-repeat;
background-size: cover;
align-content: center;
}
</style>
<script src="js/script.js" type="text/javascript" charset="utf-8">
</script>
</head>
<body class="bg">
<center><h1>Our Menu</h1></center>
<div>
<button type="button" class="btn btn-primary btn-md" onclick="location.href = 'ordering.html'">Confirm Order</button>
<br><br>
<script type="text/javascript" charset="utf-8" async defer>
function confirm()
{
alert("Your order is on the way!");
}
</script>
</div>
<?php
if(!empty($_GET["action"])) {
switch($_GET["action"]) {
case "add":
if(!empty($_POST["quantity"])) {
$productByCode = mysqli_query($conn,"SELECT * FROM tblproduct WHERE code='" . $_GET["code"] . "'");
$row = mysqli_fetch_assoc($productByCode);
$itemArray = array($row["code"]=>array('name'=>$row["name"], 'code'=>$row["code"], 'quantity'=>$_POST["quantity"], 'price'=>$row["price"]));
if(!empty($_SESSION["cart_item"])) {
if(in_array($row["code"],array_keys($_SESSION["cart_item"]))) {
foreach($_SESSION["cart_item"] as $k => $v) {
if($row["code"] == $k) {
if(empty($_SESSION["cart_item"][$k]["quantity"])) {
$_SESSION["cart_item"][$k]["quantity"] = 0;
}
$_SESSION["cart_item"][$k]["quantity"] += $_POST["quantity"];
}
}
} else {
$_SESSION["cart_item"] = array_merge($_SESSION["cart_item"],$itemArray);
}
} else {
$_SESSION["cart_item"] = $itemArray;
}
}
break;
case "remove":
if(!empty($_SESSION["cart_item"])) {
foreach($_SESSION["cart_item"] as $k => $v) {
if($_GET["code"] == $k)
unset($_SESSION["cart_item"][$k]);
if(empty($_SESSION["cart_item"]))
unset($_SESSION["cart_item"]);
}
}
break;
case "empty":
unset($_SESSION["cart_item"]);
break;
}
}
?>
<div id="shopping-cart">
<div class="txt-heading">Shopping Cart <a id="btnEmpty" href="loggedmenu.php?action=empty">Empty Cart</a></div>
<?php
if(isset($_SESSION["cart_item"])){
$item_total = 0;
?>
<table cellpadding="10" cellspacing="1">
<tbody>
<tr>
<th style="text-align:left;"><strong>Name</strong></th>
<th style="text-align:left;"><strong>Code</strong></th>
<th style="text-align:right;"><strong>Quantity</strong></th>
<th style="text-align:right;"><strong>Price</strong></th>
<th style="text-align:center;"><strong>Action</strong></th>
</tr>
<?php
foreach ($_SESSION["cart_item"] as $item){
?>
<tr>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;"><strong><?php echo $item["name"]; ?></strong></td>
<td style="text-align:left;border-bottom:#F0F0F0 1px solid;"><?php echo $item["code"]; ?></td>
<td style="text-align:right;border-bottom:#F0F0F0 1px solid;"><?php echo $item["quantity"]; ?></td>
<td style="text-align:right;border-bottom:#F0F0F0 1px solid;"><?php echo "Rs".$item["price"]; ?></td>
<td style="text-align:center;border-bottom:#F0F0F0 1px solid;"><a href="loggedmenu.php?action=remove&code=<?php echo $item["code"]; ?>" class="btnRemoveAction">Remove Item</a></td>
</tr>
<?php
$item_total += ($item["price"]*$item["quantity"]);
}
?>
<tr>
<td colspan="5" align=right><strong>Total:</strong> <?php echo "Rs".$item_total; ?></td>
</tr>
</tbody>
</table>
<?php
}
?>
</div>
<?php
$conn = mysqli_connect('localhost','root','','registration');
$product_array = mysqli_query($conn, "SELECT * FROM tblproduct ORDER BY id ASC");
while($row = mysqli_fetch_assoc($product_array)) {
?>
<div class="product-item">
<form method="post" action="loggedmenu.php?action=add&code=<?php echo $row['code'] ?>">
<div class="product-image"><img style="max-width: 100%; max-height: 100%" src="menu_images/<?php echo $row["image"] ?>"></div><BR>
<div><strong><?php echo $row["name"] ?></strong></div><BR>
<div class="product-price"><?php echo "Rs.".$row["price"] ?></div><BR>
<div><input type="text" name="quantity" value="1" size="2" /><input onclick="https://imjo.in/6vwUbb" type="submit" value="Add to cart" class="btnAddAction" /></div>
</form>
</div>
<?php
}
?>
</body>
</html>
<!--div class="w3-row-padding w3-padding-16 w3-center" id="food">
<div class="w3-quarter">
<a href="cart.html"> <img src="sandwich.jpg" alt="Sandwich" style="width:100%"></a>
<a href="cart.html"> <h3>The Perfect Sandwich, A Real NYC Classic</h3></a>
</div>
<div class="w3-quarter">
<img src="rolls.jpg" alt="rolls" style="width:70%">
<h3>Let Me Tell You About This Rolls</h3>
</div>
<div class="w3-quarter">
<img src="sub.jpg" alt="subway" style="width:110%">
<h3>Satisfy your hunger with a footlong</h3>
</div>
<div class="w3-quarter">
<img src="biscuits.jpg" alt="biscuits" style="width:80%">
<h3>Anytime is biscuits time</h3>
</div>
</div>
<! Second Photo Grid>
<div class="w3-row-padding w3-padding-16 w3-center">
<div class="w3-quarter">
<img src="water.png" alt="water" style="width:100%">
<h3>All u Need </h3>
</div>
<div class="w3-quarter">
<img src="juice.jpg" alt="juice" style="width:105%">
<h3>Fruit-juices</h3>
</div>
<div class="w3-quarter">
<img src="fruits.jpg" alt="fruits" style="width:90%">
<h3>Cut-fruits</h3>
</div>
<div class="w3-quarter">
<img src="salad.jpg" alt="salad" style="width:100%">
<h3>Salads</h3>
</div>
</div-->