-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.php
executable file
·249 lines (213 loc) · 9.26 KB
/
index.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
<?php
session_start();
if (!isset($_SESSION['logged_in'])) {
$nav = 'includes/nav.php';
} else {
$nav = 'includes/navconnected.php';
$idsess = $_SESSION['id'];
}
require 'includes/header.php';
require $nav; ?>
<style>
.autocomplete {
/*the container must be positioned relative:*/
position: relative;
display: block;
}
.autocomplete-items {
color: #26a69a;
font: 16px Roboto, sans-serif;
position: absolute;
border: 1px solid #d4d4d4;
border-bottom: none;
border-top: none;
z-index: 99;
/*position the autocomplete items to be the same width as the container:*/
top: 100%;
left: 0;
right: 0;
}
.autocomplete-items div {
padding-bottom: 20px;
padding-top: 20px;
padding-left: 30px;
cursor: pointer;
background-color: #fff;
}
.autocomplete-items div:hover {
/*when hovering an item:*/
color: #26a69a;
background-color: #e9e9e9;
}
.autocomplete-active {
/*when navigating through the items using the arrow keys:*/
background-color: DodgerBlue !important;
color: #ffffff;
}
</style>
<div class="container-fluid home" id="top">
<div class="container search">
<nav class="animated slideInUp wow">
<div class="nav-wrapper">
<form method="GET" action="search.php">
<div class="input-field">
<input id="search" class="searching" type="search" name='searched' required>
<label for="search"><i class="material-icons">search</i></label>
</div>
<div class="center-align">
<button type="submit" name="search" class="blue waves-light miaw waves-effect btn hide">Search</button>
</div>
</form>
</div>
</nav>
</div>
</div>
<div class="container most">
<div class="row">
<?php
include 'db.php';
// selecting product available in largest quantity
$queryfirst = "SELECT
product.id as 'id',
product.name as 'name',
product.price as 'price',
product.thumbnail as 'thumbnail',
SUM(command.quantity) as 'total',
command.statut,
command.id_product
FROM product, command
WHERE product.id = command.id_product AND command.statut = 'paid'
GROUP BY product.id
ORDER BY SUM(command.quantity) DESC LIMIT 6";
$resultfirst = $connection->query($queryfirst);
if ($resultfirst->num_rows > 0) {
// output data of each row
while ($rowfirst = $resultfirst->fetch_assoc()) {
$id_best = $rowfirst['id'];
$name_best = $rowfirst['name'];
$price_best = $rowfirst['price'];
$thumbnail_best = $rowfirst['thumbnail'];
$totalsold = $rowfirst['total'];
?>
<div class="col s12 m4">
<div class="card hoverable animated slideInUp wow">
<div class="card-image">
<a href="product.php?id=<?= $id_best; ?>"><img src="products/<?= $thumbnail_best; ?>"></a>
<span class="card-title blue-text"><?= $name_best; ?></span>
<a href="product.php?id=<?= $id_best; ?>" class="btn-floating blue halfway-fab waves-effect waves-light right"><i class="material-icons">add</i></a>
</div>
<div class="card-content">
<div class="container">
<div class="row">
<div class="col s6">
<p class="white-text"><i class="left fa fa-dollar"></i> <?= $price_best; ?></p>
</div>
<div class="col s6">
<p class="white-text"><i class="left fa fa-shopping-basket"></i> <?= $totalsold; ?></p>
</div>
</div>
</div>
</div>
</div>
</div>
<?php }
} ?>
</div>
</div>
<div class="container-fluid center-align categories">
<a href="#category" class="button-rounded btn-large waves-effect waves-light">Categories</a>
<div class="container" id="category">
<div class="row">
<?php
//get categories
$querycategory = "SELECT id, name, icon FROM category";
$total = $connection->query($querycategory);
if ($total->num_rows > 0) {
// output data of each row
while ($rowcategory = $total->fetch_assoc()) {
$id_category = $rowcategory['id'];
$name_category = $rowcategory['name'];
$icon_category = $rowcategory['icon'];
?>
<div class="col s12 m4">
<div class="card hoverable animated slideInUp wow">
<div class="card-image">
<a href="category.php?id=<?= $id_category; ?>"><img src="src/img/<?= $icon_category; ?>.png" alt=""></a>
<span class="card-title black-text"><?= $name_category; ?></span>
</div>
</div>
</div>
<?php }
} ?>
</div>
</div>
</div>
<div class="container-fluid about" id="about">
<div class="container">
<div class="row">
<div class="col s12 m6">
<div class="card animated slideInUp wow">
<div class="card-image">
<img src="src/img/about.jpg" alt="">
</div>
</div>
</div>
<div class="col s12 m6">
<h3 class="animated slideInUp wow">About Us</h3>
<div class="divider animated slideInUp wow"></div>
<p class="animated slideInUp wow">This project aims to implement an e-commerce website which enables
stores to migrate online. We are making use of PHP and MySQL based dynamically generated web pages
to allow purchasing of items. We are going to implement a cart system to allow customers to store
their items. We are also going to implement an authentication system, to differentiate between
regular and logged in customers, by making use of MySQL database. The users are handled using
PHP sessions to allow them to make changes to the cart. These changes are stored as session variables
so that the user can come back and restore his previous session. </p>
</div>
</div>
</div>
</div>
<div class="container contact" id="contact">
<div class="row">
<form action="https://postmail.invotes.com/send" method="post" id="email_form" class="col s12 animated slideInUp wow">
<h3 class="animated slideInUp wow">Contact Us</h3>
<div class="row">
<div class="input-field col s12 m6">
<i class="material-icons prefix">account_circle</i>
<input id="icon_prefix" name="subject" type="text" class="validate">
<label for="icon_prefix">Subject</label>
</div>
<div class="input-field col s12 m6">
<i class="material-icons prefix">email</i>
<input id="email" name="reply_to" type="email" class="validate">
<label for="email" data-error="wrong" data-success="right">Email</label>
</div>
<div class="input-field col s12 ">
<i class="material-icons prefix">message</i>
<textarea id="icon_prefix2" class="materialize-textarea" type="text" name="text" rows="4"" style=" resize: vertical;min-height: 8rem;" required></textarea>
<label for="icon_prefix2">Your message</label>
</div>
<!-- Go to https://postmail.invotes.com/ to get an access token -->
<input type="hidden" name="access_token" value="" />
<input type="hidden" name="success_url" value="." />
<input type="hidden" name="error_url" value=".?err=1" />
<div class="center-align">
<button id="submit_form" type="submit" name="contact" value="Send" class="button-rounded btn-large waves-effect waves-light">Submit</button>
</div>
<p>Powered by <a href="https://postmail.invotes.com" target="_blank">PostMail</a></p>
</div>
</form>
</div>
</div>
<?php
require 'includes/secondfooter.php';
require 'includes/footer.php'; ?>
<script>
var submitButton = document.getElementById("submit_form");
var form = document.getElementById("email_form");
form.addEventListener("submit", function(e) {
setTimeout(function() {
submitButton.value = "Sending...";
submitButton.disabled = true;
}, 1);
});
</script>