-
Notifications
You must be signed in to change notification settings - Fork 9
/
browse.php
executable file
·173 lines (150 loc) · 4.89 KB
/
browse.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
<?php
session_start();
include("db.php");
if (isset($_SESSION["sess_id"])) {
$usr_id = $_SESSION["sess_id"];
if ($_SESSION["sess_status"] == "admin") {
header('location: admin/pnl_user');
}
if ($_SESSION["sess_status"] == "shop") {
header('location: shop/pnl_order');
}
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
}
if (isset($_GET['act'])) {
if ($_GET['act'] == 'add') {
if (!isset($_SESSION['sess_cart'])) {
$_SESSION['sess_cart'] = array();
}
$_SESSION['sess_cart'][$id] += 1;
header('location: browse');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="favicon.ico">
<title>Food Ordering Management System</title>
<link rel="stylesheet" href="bootstrap/css/all.min.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<script src="bootstrap/js/jquery-3.4.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<style type="text/css">
.content {
background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)),
url('https://source.unsplash.com/fdlZBWIP0aM/1920x1080');
height: 100%;
background-position: center;
background-repeat: repeat;
}
</style>
</head>
<body class="content">
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light sticky-top shadow bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">FOS</a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item ">
<a class="nav-link" href="index">Home</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Browse <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="checkout">Checkout</a>
</li>
<li class="nav-item">
<a class="nav-link" href="order">Status</a>
</li>
</ul>
<div class="my-2 my-lg-0">
<ul class="navbar-nav ml-auto">
<?php
if (isset($_SESSION['sess_id'])) {
?>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink-333" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-user"></i> </a>
<div class="dropdown-menu dropdown-menu-right dropdown-default" aria-labelledby="navbarDropdownMenuLink-333">
<a class="dropdown-item" href="profile">Profile</a>
<a class="dropdown-item" href="action?act=lgout">Logout</a>
</div>
</li>
<?php
} else {
?>
<a href="index?act=login" class="btn btn-outline-success my-2 my-sm-0">Login</a>
<?php
}
?>
</ul>
</div>
</div>
</nav>
<!-- Content -->
<div class="container my-5" id="browse_box">
<div class="row">
<div class="col-8">
<h2 class="display-4 text-light"><i class="fas fa-book-open"></i> Browse Menu</h2>
</div>
<div class="col-4">
<div class="input-group mt-4">
<input type="text" id="search_query" class="form-control" placeholder="Search..">
</div>
</div>
</div>
<?php
$query = "SELECT * from fds_ctlog";
$result = mysqli_query($conn, $query);
$tot_item = mysqli_num_rows($result);
?>
<div class="row">
<div class="col ">
<div class="card-columns m-auto text-center pt-5" id="display_area">
<?php
while ($row = mysqli_fetch_assoc($result)) {
$itm_id = $row['ctlog_id'];
$itm_name = $row['ctlog_nme'];
$itm_prc = $row['ctlog_prc'];
$itm_desc = $row['ctlog_desc'];
$itm_shp = $row['ctlog_shp'];
$itm_img = $row['ctlog_img'];
?>
<div class="card text-left" style="width: 18rem;">
<?php
if ($itm_img != null) {
echo '<img class="card-img-top" src="img/menu/' . $itm_img . '" alt="Card image cap">';
} else {
echo '<img class="card-img-top" src="https://dummyimage.com/640x360/f0f0f0/aaa" alt="Card image cap">';
}
?>
<div class="card-body">
<h5 class="card-title text-capitalize"><?php echo $itm_name; ?></h5>
<p class="card-text text-muted"><?php echo $itm_desc; ?></p>
<p class="card-text text-capitalize"><?php echo $itm_shp . "'s Shop"; ?></p>
</div>
<div class="card-footer text-right" id="<?php echo encryptIt($itm_id); ?>">
<h5 class="card-text float-left text-success">RM <?php echo number_format($itm_prc, 2); ?></h5>
<a href="browse?act=add&id=<?php echo encryptIt($itm_id); ?>" class="btn btn-success ">Add to cart</a>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
<!-- Script -->
<script src="bootstrap/js/app.js"></script>
</body>
</html>