-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.php
184 lines (168 loc) · 7.14 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
<?php
session_start();
require("./connection/connect.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Ayuruveda | About Us</title>
<!-- Common Tags -->
<?php require('includes/head.php') ?>
</head>
<!-- Header Style -->
<style>
header {
width: 100%;
height: 40px;
background-color: #07660a;
}
header .col-11 {
text-align: end;
}
header .account-bar {
display: flex;
flex-direction: end;
}
header .account-bar a {
color: white;
margin: 4px;
display: flex;
}
header .account-bar a i {
margin-top: 4px;
}
header .account-bar .account {
margin-top: 7px;
}
header .account-bar .account:hover {
text-decoration: none;
cursor: pointer;
}
</style>
<body>
<!-- Header -->
<header>
<div class="container">
<div class="row">
<?php
if(isset($_SESSION['email'])){
echo '<div class="col-lg-3">
<div class="social d-flex pt-2 pb-2">
<i class="fa-brands fa-facebook pr-4" style="font-size:22px; color: white;"></i>
<i class="fa-brands fa-instagram pr-4" style="font-size:22px; color: white;"></i>
<i class="fa-brands fa-twitter pr-4" style="font-size:22px; color: white;"></i>
<i class="fa-brands fa-youtube pr-4" style="font-size:22px; color: white;"></i>
</div></div>
<div class="col-lg-6"></div>
<div class="col-lg-3">
<div class="account-bar">
<a class="account text-light" href="account.php">
<i class="fa-solid fa-circle-user"></i>
My Account
<span class="disabled" style="font-size: 30px; margin-top: -10px;">|</span>
</a>
<form method="post">
<a class="btn btn-outline-light btn-sm" href="logout.php"><i
class="fa-solid fa-arrow-right-from-bracket"></i> Logout</a>
</form>
</div>
</div>';
}else{
echo ' <div class="col-lg-3">
<div class="social d-flex pt-2 pb-2">
<i class="fa-brands fa-facebook pr-4" style="font-size:22px; color: white;"></i>
<i class="fa-brands fa-instagram pr-4" style="font-size:22px; color: white;"></i>
<i class="fa-brands fa-twitter pr-4" style="font-size:22px; color: white;"></i>
<i class="fa-brands fa-youtube pr-4" style="font-size:22px; color: white;"></i>
</div>
</div>
<div class="col-lg-8"></div>
<div class="col-lg-1">
<div class="account-bar">
<a class="btn btn-outline-light btn-sm" href="login.php">
<i class="fa-solid fa-user"></i>
Login
</a>
</div>
</div>
'
;
}
?>
</div>
</div>
</header>
<!-- Navbar and Header -->
<?php require('includes/navbar.php') ?>
<section>
<div class="container">
<div class="" id="message"></div>
<div class="row mt-4 pb-3 justify-content-center">
<?php
include './connection/connect.php';
$stmt = $con->prepare("SELECT * FROM product");
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc()):
?>
<div class="col-md-4" style="text-align: center;">
<div class="card" style="width: 18rem;">
<img src="<?= $row['product_image']; ?>" class="card-img-top" alt="...">
<div class="card-body">
<h6 class="card-title bold"><b><?= $row['product_name']; ?></b></h6>
<h6 class="card-title bold">Rs. <?= $row['product_price']; ?> /=</h6>
<form action="" method="post" class="form-submit">
<input type="hidden" class="pid" value="<?= $row['id']; ?>">
<input type="hidden" class="pname" value="<?= $row['product_name']; ?>">
<input type="hidden" class="pprice" value="<?= $row['product_price']; ?>">
<input type="hidden" class="pimage" value="<?= $row['product_image']; ?>">
<input type="hidden" class="pcode" value="<?= $row['product_code']; ?>">
<div class="btnrow">
<input class="btn btn-primary addItemBtn" onclick="submit()" value="Add to cart">
</div>
</form>
</div>
</div>
</div>
<?php endwhile;?>
</div>
</div>
</section>
<script type="text/javascript">
$(document).ready(function(){
$(".addItemBtn").click(function(e){
e.preventDefault();
var $form = $(this).closest(".form-submit");
var pid = $form.find(".pid").val();
var pname = $form.find(".pname").val();
var pprice = $form.find(".pprice").val();
var pimage = $form.find(".pimage").val();
var pcode = $form.find(".pcode").val();
$.ajax({
url: 'action.php',
method: 'post',
data: {pid:pid,pname:pname,pprice:pprice,pimage:pimage,pcode:pcode},
success:function(response){
$("#message").html(response);
window.scrollTo(0,0);
load_cart_item_number();
}
});
});
load_cart_item_number();
function load_cart_item_number(){
$.ajax({
url: 'action.php',
method: 'get',
data: {cartItem:"cart_item"},
success:function(response){
$("#cart-item").html(response);
}
});
}
});
</script>
<!-- Footer -->
<?php require('includes/footer.php') ?>
</body>
</html>