-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprofile.php
279 lines (181 loc) · 6.66 KB
/
profile.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
<?php
session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> -->
<meta charset="UTF-8">
<!-- Important to make website responsive -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Restaurant Website</title>
<!-- Link our CSS file -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/form.css">
</head>
<body>
<?php require('navbar.php'); ?>
<!-- Navbar Section Ends Here -->
<!-- fOOD sEARCH Section Starts Here -->
<section class="food-search text-center">
<div class="container">
<h1>My Profile</h1>
</div>
</section>
<!-- fOOD sEARCH Section Ends Here -->
<!-- MAIN CODE TO ACCESS AND OUTPUT EACH ITEM -->
<?php
include 'connect.php';
if(isset($_POST["pay"]))
{
$sql= "INSERT INTO payment(cardholder, cardNumber, cvv, exp, uid) VALUES(".json_encode($_POST['cardName']).", ".json_encode($_POST['cardNum']).", ".intval($_POST['cvv']).", ".json_encode($_POST['exp']).", ".$_SESSION["uid"].");";
mysqli_query($db, $sql);
}
if(isset($_POST['subAdd']))
{$sql= "INSERT INTO customerDetails(address,phone,postal,uid) VALUES(".json_encode($_POST['add']).", ".json_encode($_POST['ph']).", ".json_encode($_POST['pos']).", ".$_SESSION["uid"].");";
$res = $db->query($sql);
header("location: profile.php");}
if(isset($_POST['del_add']))
{print_r('isset');
$sql= "DELETE FROM customerDetails WHERE CDid=".intval($_POST['add_id']).";";
$resd = $db->query($sql);
header("location: profile.php");
}
if(isset($_POST['del_pay']))
{print_r('isset');
$sql= "DELETE FROM payment WHERE pid=".intval($_POST['pay_id']).";";
$resd = $db->query($sql);
header("location: profile.php");
}
$rows=0;
$sql= "SELECT * FROM customerDetails WHERE uid=".$_SESSION["uid"];
$res = $db->query($sql);
if($res==True){
$rows=mysqli_num_rows($res);
if($rows>0)
echo '<h1>Saved Address</h1><div class="boxm" style="display: grid">';
while ($obj = $res -> fetch_object()) {
echo '
<div class="boxmin2" style="background-color: rgb(161 193 197)" id="OFood">
<div class="food-menu-desc">
<h4>'.$obj->postal.'</h4>
<p class="food-price">'.$obj->phone.'</p>
<p class="food-detail">'.$obj->address.
'</p>
<br>
<form method="post" action ="'.$_SERVER["PHP_SELF"].'">
<input
type="hidden" name="add_id" class="btn btn-primary" value='.$obj->CDid.'>
<input
type="submit" name="del_add" class="btn btn-primary" value="delete">
</form>
</div>
</div>
';
}
if($rows>0)
echo '</div>';
}
$rows=0;
$sqlP= "SELECT * FROM payment WHERE uid=".$_SESSION["uid"];
$resP = $db->query($sqlP);
if($resP==True){
$rows=mysqli_num_rows($resP);
if($rows>0)
echo '<h1>Saved Payments</h1><div class="boxm" style="display: grid">';
while ($obj = $resP -> fetch_object()) {
echo '
<div class="boxmin2" id="OFood">
<div class="food-menu-desc">
<h4 >'.$obj->cardholder.'</h4>
<p class="food-price" >'.$obj->cardNumber.'</p>
<p class="food-detail" >'.$obj->cvv.
'</p>
<p class="food-price" >'.$obj->exp.'</p>
<br>
<form method="post" action ="'.$_SERVER["PHP_SELF"].'">
<input
type="hidden" name="pay_id" class="btn btn-primary" value='.$obj->pid.'>
<input
type="submit" name="del_pay" class="btn btn-primary" value="delete">
</form>
</div>
</div>
';
}
if($rows>0)
echo '</div>';
}
if($rows==0) print_r('none');
?>
</div>
<br>
<div>
<div class="boxm">
<div class="boxmin2" style="background-color: rgb(195 195 195);">
<form class="login" method="post">
<h1>New Payment</h1>
<div class="field">
<input type="text" placeholder="Name on card" name="cardName" required />
</div>
<div class="field">
<input type="text" placeholder="cardNum" name="cardNum" required />
</div>
<div class="field">
<input type="text" placeholder="Expiry" name="exp" required />
</div>
<div class="field">
<input type="text" placeholder="cvv" name="cvv" required />
</div>
<div class="field btn">
<div class="btn-layer"></div>
<input type="submit" name="pay" class="btn btn-primary" value="Save" />
</div>
</form>
</div>
<div class="boxmin2" style="background-color: rgb(195 195 195);" id="OFood">
<form class="login" method="post">
<h1>New Address</h1>
<div class="field">
<input type="text" placeholder="address" name="add" required />
</div>
<div class="field">
<input type="text" placeholder="postal" name="pos" required />
</div>
<div class="field">
<input type="text" placeholder="phone" name="ph" required />
</div>
<div class="field btn">
<div class="btn-layer"></div>
<input type="submit" name="subAdd" class="btn btn-primary" value="Save" />
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- social Section Starts Here -->
<section class="social">
<div class="container text-center">
<ul>
<li>
<a href="#"><img src="https://img.icons8.com/fluent/50/000000/facebook-new.png"/></a>
</li>
<li>
<a href="#"><img src="https://img.icons8.com/fluent/48/000000/instagram-new.png"/></a>
</li>
<li>
<a href="https://github.com/keerat21"><img src="images/gitIcon.gif" width="50" height="50"/></a>
</li>
</ul>
</div>
</section>
<!-- social Section Ends Here -->
<!-- footer Section Starts Here -->
<section class="footer">
<div class="container text-center">
<p>All rights reserved. University project.Current page work done onit By <a href="https://github.com/keerat21">Keerat Tanwar</a></p>
</div>
</section>
</body>
</html>