-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoccasion.php
368 lines (270 loc) · 11.9 KB
/
occasion.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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
<?php
// session_start();
include 'php/config.php';
// if(isset($_SESSION['ID'])){
// $user_id = $_SESSION['ID'];
// }else{
// $user_id = '';
// }
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!isset($_SESSION['ID'])) {
// Redirect to login page if not logged in
header("Location: login.php");
exit();
}
$user_id = $_SESSION['ID'];
$product_id = $_POST['product_id'];
$product_name = $_POST['product_name'];
$product_price = $_POST['product_price'];
$quantity = $_POST['quantity'];
$image_url = $_POST['image_url'];
$total = $product_price * $quantity;
// SQL query: Insert into cart, or if there's a duplicate entry, update the quantity.
$sql = "INSERT INTO cart(user_id, product_id, product_name, product_price, quantity, image_url, total)
VALUES (?, ?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE quantity = quantity + ?";
// Prepare the statement
if ($stmt = $con->prepare($sql)) {
// Bind parameters including the one for the `ON DUPLICATE KEY UPDATE` clause
$stmt->bind_param("isssisis", $user_id, $product_id, $product_name, $product_price, $quantity, $image_url, $total, $quantity);
// Execute the statement
if ($stmt->execute()) {
header("Location: occasion.php");
exit();
} else {
echo "Error! Could not add to cart: " . $stmt->error;
}
$stmt->close();
} else {
echo "Error preparing statement: " . $con->error;
}
}
$con->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Khloris</title>
<link rel="stylesheet" href="ui khloris/occasion.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css"
/>
<!-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap" rel="stylesheet">
<style>
.left-nav {
position: fixed;
left: 0;
top: 50%;
transform: translateY(-50%);
display: flex;
flex-direction: column;
gap: 20px;
background-color: #f8f8f8;
padding: 10px;
border-radius: 0 8px 8px 0;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
z-index: 10;
}
.nav-item {
position: relative;
display: flex;
align-items: center;
text-decoration: none;
color: #333;
transition: color 0.3s;
overflow: visible;
}
.nav-icon {
width: 60px;
height: 60px;
display: block;
transition: transform 0.3s;
}
.nav-text {
position: absolute;
left: 80px;
opacity: 0;
visibility: hidden;
background-color: #fff;
padding: 5px 10px;
border-radius: 5px;
white-space: nowrap;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
transform: translateX(-10px);
pointer-events: none;
font-size: 20px;
}
.nav-item:hover .nav-text {
opacity: 1;
visibility: visible;
transform: translateX(0);
}
.nav-item:hover .nav-icon {
transform: scale(1.1);
}
</style>
</head>
<body>
<!-- <header>
<input type="checkbox" name="" id="toggler" />
<label for="toggler" class="fas fa-bars"></label>
<a href="#" class="logo">Khloris<span>.</span></a>
<nav class="navbar">
<a href="#home">Home</a>
<a href="#Customization">Customization</a>
<a href="flowerpage.html">Flowers</a>
<a href="#Occassions">Occassions</a>
</nav>
<div class="icons">
<a href="" class="fas fa-shopping-cart"></a>
<a href="logout.php" class="fa-solid fa-right-from-bracket" onclick="return confirmLogout()"></a>
</div>
</header> -->
<?php include 'header.php'; ?>
<div class="left-nav">
<a href="#prdctsoccassion" class="nav-item">
<img src="https://res.cloudinary.com/dzvd6o0og/image/upload/v1732100729/vecteezy_ai-generated-bouquet-of-flowers-isolated-on-transparent_41856468_osknfh.png" alt="Sunflowers" class="nav-icon">
<span class="nav-text">Birthday</span>
</a>
<a href="#prdctsoccassion-anniv" class="nav-item">
<img src="https://res.cloudinary.com/dzvd6o0og/image/upload/v1732100833/vecteezy_rose-bouquet-3d-ornament_45931769_nz5f5t.png" alt="Roses" class="nav-icon">
<span class="nav-text">Anniversary</span>
</a>
<a href="#prdctsoccassion-funeral" class="nav-item">
<img src="https://res.cloudinary.com/dzvd6o0og/image/upload/v1732100729/pngwing.com_r4g28q.png" alt="Tulips" class="nav-icon">
<span class="nav-text">Funeral</span>
</a>
</div>
<section class="prdctsoccassion" id="prdctsoccassion">
<div class="bg-imagebirthday"></div>
<div class="filter-blur-bday"><h2 class="bday-header">Happy Birthday <span>Flowers</span></h2></div>
</div>
<h3 class="bday-h3">A <span>Flower</span> Gift For A Birthday Celebrant</h3>
<p class="bday-p">May your birthday be as beautiful and bright as a garden in full bloom, filled with the <br> fragrance of love, the colors of joy, and the warmth of friendship. Happy Birthday!</p>
<div class="box-container">
<?php
$sql= "SELECT * FROM products WHERE type_id=5";
$result= $con -> query($sql);
if ($result -> num_rows > 0){
while ($row = $result -> fetch_assoc()) {
echo '<div class="flwrbox">';
echo' <div class="flwrimg">';
echo ' <img src="'. $row["image_url"].'" alt="'.$row["name"].'"/>';
echo ' <div class="icons">';
echo' <form action="" method="POST">';
echo ' <input type="hidden" name="product_id" value="' . $row["product_id"] . '">';
echo ' <input type="hidden" name="product_name" value="' . $row["name"] . '">';
echo ' <input type="hidden" name="product_price" value="' . $row["price"] . '">';
echo ' <input type="hidden" name="quantity" value="1">';
echo ' <input type="hidden" name="image_url" value="' . $row["image_url"] . '">';
echo ' <div class="btn-div"><button type="submit" class="button">Add to cart</button></div>';
echo '</form>';
echo' </div>';
echo ' </div>';
echo' <div class="imgcontent">';
echo' <h3>'. $row["name"] .'</h3>';
echo' <div class="price">P'. $row["price"] . '</div>';
echo' </div>';
echo' </div>';
}
}else {
echo "No products found";
}
// $con->close();
// ?>
</section>
<!-- anniv -->
<section class="prdctsoccassion-anniv" id="prdctsoccassion-anniv">
<div class="bg-image-anniv"></div>
<div class="filter-blur-anniv"><h2 class="anniv-header">Anniversary <span>Flowers</span></h2></div>
</div>
<h3 class="anniv-h3">The Perfect <span>Flower</span> Bouquet for Anniversary</h3>
<p class="anniv-p">May the blossoms of your love continue to flourish, filling your lives with beauty, joy, and <br> cherished memories. Wishing you a wonderful anniversary filled with blooming <br>happines.</p>
<div class="box-container">
<?php
$sql= "SELECT * FROM products WHERE type_id=6";
$result= $con -> query($sql);
if ($result -> num_rows > 0){
while ($row = $result -> fetch_assoc()) {
echo '<div class="flwrbox">';
echo' <div class="flwrimg">';
echo ' <img src="'. $row["image_url"].'" alt="'.$row["name"].'"/>';
echo ' <div class="icons">';
echo' <form action="" method="POST">';
echo ' <input type="hidden" name="product_id" value="' . $row["product_id"] . '">';
echo ' <input type="hidden" name="product_name" value="' . $row["name"] . '">';
echo ' <input type="hidden" name="product_price" value="' . $row["price"] . '">';
echo ' <input type="hidden" name="quantity" value="1">';
echo ' <input type="hidden" name="image_url" value="' . $row["image_url"] . '">';
echo ' <div class="btn-div"><button type="submit" class="button">Add to cart</button></div>';
echo '</form>';
echo' </div>';
echo ' </div>';
echo' <div class="imgcontent">';
echo' <h3>'. $row["name"] .'</h3>';
echo' <div class="price">P'. $row["price"] . '</div>';
echo' </div>';
echo' </div>';
}
}else {
echo "No products found";
}
// $con->close();
// ?>
</section>
<!-- funeral -->
<section class="prdctsoccassion-funeral" id="prdctsoccassion-funeral">
<div class="bg-image-funeral"></div>
<div class="filter-blur-funeral"><h2 class="funeral-header">Funeral <span>Flowers</span></h2></div>
</div>
<h3 class="funeral-h3">Send Sympathy <span>Flower</span></h3>
<p class="funeral-p">May these flowers bring solace to you in this time of sorrow. Though words can hardly <br> ease your pain, may their beauty remind you of the love and cherished memories that will <br>always remain in your heart.</p>
<div class="box-container">
<?php
$sql= "SELECT * FROM products WHERE type_id=7";
$result= $con -> query($sql);
if ($result -> num_rows > 0){
while ($row = $result -> fetch_assoc()) {
echo '<div class="flwrbox">';
echo' <div class="flwrimg">';
echo ' <img src="'. $row["image_url"].'" alt="'.$row["name"].'"/>';
echo ' <div class="icons">';
echo' <form action="" method="POST">';
echo ' <input type="hidden" name="product_id" value="' . $row["product_id"] . '">';
echo ' <input type="hidden" name="product_name" value="' . $row["name"] . '">';
echo ' <input type="hidden" name="product_price" value="' . $row["price"] . '">';
echo ' <input type="hidden" name="quantity" value="1">';
echo ' <input type="hidden" name="image_url" value="' . $row["image_url"] . '">';
echo ' <div class="btn-div"><button type="submit" class="button">Add to cart</button></div>';
echo '</form>';
echo' </div>';
echo ' </div>';
echo' <div class="imgcontent">';
echo' <h3>'. $row["name"] .'</h3>';
echo' <div class="price">P'. $row["price"] . '</div>';
echo' </div>';
echo' </div>';
}
}else {
echo "No products found";
}
$con->close();
?>
</section>
<!-- footer -->
<?php include 'footer.php'; ?>
<script>
function confirmLogout() {
return confirm("Are you sure you want to log out?");
}
</script>
</body>
</html>