-
Notifications
You must be signed in to change notification settings - Fork 0
/
product.php
380 lines (341 loc) · 12.9 KB
/
product.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
369
370
371
372
373
374
375
376
377
378
379
380
<?php
session_start();
include 'dbconnect.php';
$idproduk = $_GET['idproduk'];
if(isset($_POST['addprod'])){
if(!isset($_SESSION['log']))
{
header('location:login.php');
} else {
$ui = $_SESSION['id'];
$cek = mysqli_query($conn,"select * from cart where userid='$ui' and status='Cart'");
$liat = mysqli_num_rows($cek);
$f = mysqli_fetch_array($cek);
$orid = $f['orderid'];
//kalo ternyata udeh ada order id nya
if($liat>0){
//cek barang serupa
$cekbrg = mysqli_query($conn,"select * from detailorder where idproduk='$idproduk' and orderid='$orid'");
$liatlg = mysqli_num_rows($cekbrg);
$brpbanyak = mysqli_fetch_array($cekbrg);
$jmlh = $brpbanyak['qty'];
//kalo ternyata barangnya ud ada
if($liatlg>0){
$i=1;
$baru = $jmlh + $i;
$updateaja = mysqli_query($conn,"update detailorder set qty='$baru' where orderid='$orid' and idproduk='$idproduk'");
if($updateaja){
echo " <div class='alert alert-success'>
Barang sudah pernah dimasukkan ke keranjang, jumlah akan ditambahkan
</div>
<meta http-equiv='refresh' content='1; url= product.php?idproduk=".$idproduk."'/>";
} else {
echo "<div class='alert alert-warning'>
Gagal menambahkan ke keranjang
</div>
<meta http-equiv='refresh' content='1; url= product.php?idproduk=".$idproduk."'/>";
}
} else {
$tambahdata = mysqli_query($conn,"insert into detailorder (orderid,idproduk,qty) values('$orid','$idproduk','1')");
if ($tambahdata){
echo " <div class='alert alert-success'>
Berhasil menambahkan ke keranjang
</div>
<meta http-equiv='refresh' content='1; url= product.php?idproduk=".$idproduk."'/> ";
} else { echo "<div class='alert alert-warning'>
Gagal menambahkan ke keranjang
</div>
<meta http-equiv='refresh' content='1; url= product.php?idproduk=".$idproduk."'/> ";
}
};
} else {
//kalo belom ada order id nya
$oi = crypt(rand(22,999),time());
$bikincart = mysqli_query($conn,"insert into cart (orderid, userid) values('$oi','$ui')");
if($bikincart){
$tambahuser = mysqli_query($conn,"insert into detailorder (orderid,idproduk,qty) values('$oi','$idproduk','1')");
if ($tambahuser){
echo " <div class='alert alert-success'>
Berhasil menambahkan ke keranjang
</div>
<meta http-equiv='refresh' content='1; url= product.php?idproduk=".$idproduk."'/> ";
} else { echo "<div class='alert alert-warning'>
Gagal menambahkan ke keranjang
</div>
<meta http-equiv='refresh' content='1; url= product.php?idproduk=".$idproduk."'/> ";
}
} else {
echo "gagal bikin cart";
}
}
}
};
?>
<!DOCTYPE html>
<html>
<head>
<title>Tokopekita - Produk</title>
<!-- for-mobile-apps -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="Tokopekita, Richard's Lab" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- //for-mobile-apps -->
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<!-- font-awesome icons -->
<link href="css/font-awesome.css" rel="stylesheet">
<!-- //font-awesome icons -->
<!-- js -->
<script src="js/jquery-1.11.1.min.js"></script>
<!-- //js -->
<link href='//fonts.googleapis.com/css?family=Raleway:400,100,100italic,200,200italic,300,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic' rel='stylesheet' type='text/css'>
<link href='//fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic' rel='stylesheet' type='text/css'>
<!-- start-smoth-scrolling -->
<script type="text/javascript" src="js/move-top.js"></script>
<script type="text/javascript" src="js/easing.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
});
});
</script>
<!-- start-smoth-scrolling -->
</head>
<body>
<!-- header -->
<div class="agileits_header">
<div class="container">
<div class="w3l_offers">
<p>DAPATKAN PENAWARAN MENARIK KHUSUS HARI INI, BELANJA SEKARANG!</p>
</div>
<div class="agile-login">
<ul>
<?php
if(!isset($_SESSION['log'])){
echo '
<li><a href="registered.php"> Daftar</a></li>
<li><a href="login.php">Masuk</a></li>
';
} else {
if($_SESSION['role']=='Member'){
echo '
<li style="color:white">Halo, '.$_SESSION["name"].'
<li><a href="logout.php">Keluar?</a></li>
';
} else {
echo '
<li style="color:white">Halo, '.$_SESSION["name"].'
<li><a href="admin">Admin Panel</a></li>
<li><a href="logout.php">Keluar?</a></li>
';
};
}
?>
</ul>
</div>
<div class="product_list_header">
<a href="cart.php"><button class="w3view-cart" type="submit" name="submit" value=""><i class="fa fa-cart-arrow-down" aria-hidden="true"></i></button>
</a>
</div>
<div class="clearfix"> </div>
</div>
</div>
<div class="logo_products">
<div class="container">
<div class="w3ls_logo_products_left1">
<ul class="phone_email">
<li><i class="fa fa-phone" aria-hidden="true"></i>Hubungi Kami : +1234 567 567</li>
</ul>
</div>
<div class="w3ls_logo_products_left">
<h1><a href="index.php">Tokopekita</a></h1>
</div>
<div class="w3l_search">
<form action="search.php" method="post">
<input type="search" name="Search" placeholder="Cari produk...">
<button type="submit" class="btn btn-default search" aria-label="Left Align">
<i class="fa fa-search" aria-hidden="true"> </i>
</button>
<div class="clearfix"></div>
</form>
</div>
<div class="clearfix"> </div>
</div>
</div>
<!-- //header -->
<!-- navigation -->
<div class="navigation-agileits">
<div class="container">
<nav class="navbar navbar-default">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header nav_2">
<button type="button" class="navbar-toggle collapsed navbar-toggle1" data-toggle="collapse" data-target="#bs-megadropdown-tabs">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="bs-megadropdown-tabs">
<ul class="nav navbar-nav">
<li class="active"><a href="index.php" class="act">Home</a></li>
<!-- Mega Menu -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Kategori Produk<b class="caret"></b></a>
<ul class="dropdown-menu multi-column columns-3">
<div class="row">
<div class="multi-gd-img">
<ul class="multi-column-dropdown">
<h6>Kategori</h6>
<?php
$kat=mysqli_query($conn,"SELECT * from kategori order by idkategori ASC");
while($p=mysqli_fetch_array($kat)){
?>
<li><a href="kategori.php?idkategori=<?php echo $p['idkategori'] ?>"><?php echo $p['namakategori'] ?></a></li>
<?php
}
?>
</ul>
</div>
</div>
</ul>
</li>
<li><a href="cart.php">Keranjang Saya</a></li>
<li><a href="konfirmasi.php">Daftar Order</a></li>
</ul>
</div>
</nav>
</div>
</div>
<!-- //navigation -->
<!-- breadcrumbs -->
<div class="breadcrumbs">
<div class="container">
<ol class="breadcrumb breadcrumb1 animated wow slideInLeft" data-wow-delay=".5s">
<li><a href="index.php"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>Home</a></li>
<li class="active"><?php
$p = mysqli_fetch_array(mysqli_query($conn,"Select * from produk where idproduk='$idproduk'"));
echo $p['namaproduk'];
?></li>
</ol>
</div>
</div>
<!-- //breadcrumbs -->
<div class="products">
<div class="container">
<div class="agileinfo_single">
<div class="col-md-4 agileinfo_single_left">
<img id="example" src="<?php echo $p['gambar']?>" alt=" " class="img-responsive">
</div>
<div class="col-md-8 agileinfo_single_right">
<h2><?php echo $p['namaproduk'] ?></h2>
<div class="rating1">
<span class="starRating">
<?php
$bintang = '<i class="fa fa-star blue-star" aria-hidden="true"></i>';
$rate = $p['rate'];
for($n=1;$n<=$rate;$n++){
echo '<i class="fa fa-star blue-star" aria-hidden="true"></i>';
};
?>
</span>
</div>
<div class="w3agile_description">
<h4>Deskripsi :</h4>
<p><?php echo $p['deskripsi'] ?></p>
</div>
<div class="snipcart-item block">
<div class="snipcart-thumb agileinfo_single_right_snipcart">
<h4 class="m-sing">Rp<?php echo number_format($p['hargaafter']) ?> <span>Rp<?php echo number_format($p['hargabefore']) ?></span></h4>
</div>
<div class="snipcart-details agileinfo_single_right_details">
<form action="#" method="post">
<fieldset>
<input type="hidden" name="idprod" value="<?php echo $idproduk ?>">
<input type="submit" name="addprod" value="Add to cart" class="button">
</fieldset>
</form>
</div>
</div>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>
<!-- //footer -->
<div class="footer">
<div class="container">
<div class="w3_footer_grids">
<div class="col-md-4 w3_footer_grid">
<h3>Hubungi Kami</h3>
<ul class="address">
<li><i class="glyphicon glyphicon-map-marker" aria-hidden="true"></i>TokoPekita, UBSI Cikarang</li>
<li><i class="glyphicon glyphicon-envelope" aria-hidden="true"></i><a href="mailto:info@email">mrizukii@gmail.com</a></li>
<li><i class="glyphicon glyphicon-earphone" aria-hidden="true"></i>+1234567567</li>
</ul>
</div>
<div class="col-md-3 w3_footer_grid">
<h3>Tentang Kami</h3>
<ul class="info">
<li><i class="fa fa-arrow-right" aria-hidden="true"></i><a href="about.html">About Us</a></li>
</ul>
</div>
<div class="clearfix"> </div>
</div>
</div>
<div class="footer-copy">
<div class="container">
<p>© 2022 TokoPekita by Kelompok 2 | Design by <a href="http://w3layouts.com/">Shalaby.com</a></p>
</div>
</div>
</div>
<div class="footer-botm">
<div class="container">
<div class="w3layouts-foot">
<ul>
<li><a href="#" class="w3_agile_instagram"><i class="fa fa-instagram" aria-hidden="true"></i></a></li>
<li><a href="#" class="w3_agile_facebook"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
<li><a href="#" class="agile_twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a></li>
</ul>
</div>
<div class="payment-w3ls">
<img src="images/card.png" alt=" " class="img-responsive">
</div>
<div class="clearfix"> </div>
</div>
</div>
<!-- //footer -->
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- top-header and slider -->
<!-- here stars scrolling icon -->
<script type="text/javascript">
$(document).ready(function() {
var defaults = {
containerID: 'toTop', // fading element id
containerHoverID: 'toTopHover', // fading element hover id
scrollSpeed: 4000,
easingType: 'linear'
};
$().UItoTop({ easingType: 'easeOutQuart' });
});
</script>
<!-- //here ends scrolling icon -->
<!-- main slider-banner -->
<script src="js/skdslider.min.js"></script>
<link href="css/skdslider.css" rel="stylesheet">
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#demo1').skdslider({'delay':5000, 'animationSpeed': 2000,'showNextPrev':true,'showPlayButton':true,'autoSlide':true,'animationType':'fading'});
jQuery('#responsive').change(function(){
$('#responsive_wrapper').width(jQuery(this).val());
});
});
</script>
<!-- //main slider-banner -->
</body>
</html>