-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprofile.php
337 lines (306 loc) · 10.3 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
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
<?php
include('server.php');
if (!isset($_SESSION['username'])) {
$_SESSION['msg'] = "You must log in first";
header('location: signin.php');
}
$username = $_SESSION['username']['username'];
$query = "SELECT * FROM customer_profile WHERE username='$username';";
// echo $query;
$results = mysqli_query($db, $query);
if(mysqli_num_rows($results) == 1) {
$profile = mysqli_fetch_assoc($results);
$firstName = $profile['first_name'];
$lastName = $profile['last_name'];
$address = $profile['address'];
$city = $profile['city'];
$state = $profile['state'];
$zipcode = $profile['zipcode'];
$card_type = $profile['card_type'];
$card_number = $profile['card_number'];
$cvc = $profile['cvc'];
$expiration_date = $profile['expiration_date'];
} else if(mysqli_num_rows($results) == 0) {
$profile = mysqli_fetch_assoc($results);
$firstName = "-";
$lastName = "-";
$address = "-";
$city = "-";
$state = "-";
$zipcode = "-";
$card_type = "-";
$card_number = "-";
$cvc = "-";
$expiration_date = "-";
}
$substring = substr($card_number, -4);
if(isset($_POST['delete']))
{
$query = "DELETE FROM customer WHERE username='$username';";
mysqli_query($db, $query);
$query2 = "DELETE FROM customer_profile WHERE username='$username'";
mysqli_query($db, $query2);
header('location: index.php');
unset($_SESSION["cart"]);
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- Site Properties -->
<title>Your Profile</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/semantic.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/semantic.css">
<link href="https://fonts.googleapis.com/css?family=Pacifico" rel="stylesheet">
<style type="text/css">
body {
min-height: 700px;
padding: 0.5em 0em;
background: #F5EAD1 url('images/web-graphics/leaf-watermark.png');
background-size: 600px;
background-repeat: no-repeat;
background-position: left bottom;
left: -2em;
bottom: -2em;
}
#profile .container {
margin-bottom: 2em;
}
#profile .container .header span {
font-family: 'Pacifico', cursive;
}
#profile .container .header i {
padding: 0 0.5em;
}
#profile .container .right .button {
margin: 0 1em !important;
}
#profile .navbar .container .right h3 {
margin: 0 1em !important;
}
.input {
width: 100%;
}
h1 {
font-size: 5em !important;
margin-bottom: 0.5em !important;
font-family: 'Pacifico', cursive !important;
}
.button {
margin: 0 1em !important;
}
#account {
margin-top: 0.5em !important;
padding-top: 0.5em !important;
}
</style>
</head>
<body>
<!-- MASTER HEAD -->
<section id="profile">
<!-- NAV BAR -->
<div class="navbar">
<div class="ui container">
<div class="ui large secondary menu">
<div class="header item">
<span>something simple.</span>
<i class="leaf icon"></i>
</div>
<a class="item" href="home.php">Home</a>
<a href="home.php#about" class="item">About</a>
<a href="home.php#about" class="item">Team</a>
<a href="home.php#contact" class="item">Contact</a>
<div class="right item">
<h3>Welcome, <?php echo $_SESSION['username']['username']; ?>!</h3>
<a class="ui primary button" href="profile.php">Profile</a>
<a class="ui negative button" href="pantry.php?action=logout">Log Out</a>
</div>
</div>
</div>
</div>
<div class="ui middle aligned center aligned grid container">
<div class="column">
<h1 class="ui left aligned header">
Profile
</h1>
<div class="ui grid container">
<div class="four wide column">
<div class="ui green vertical menu">
<a id="accountSection" class="item active">
<h4 class="ui header">Account</h4>
<p>Includes your name, username, and password</p>
</a>
<a id="shippingSection" class="item">
<h4 class="ui header">Shipping</h4>
<p>Add or remove shipping addresses</p>
</a>
<a id="paymentSection" class="item">
<h4 class="ui header">Payment</h4>
<p>Add or remove payment information</p>
</a>
</div>
</div>
<div class="twelve wide stretched column">
<div class="ui segment">
<!-- RENDER WHEN ACCOUNT IS ACTIVE -->
<div id="account" class="ui grid">
<div class="row">
<div class="sixteen wide left aligned column">
<h2><strong>Account Details</strong></h2>
</div>
</div>
<div class="row">
<div class="six wide left aligned column">
<h3><strong>Name</strong></h3>
</div>
<div class="ten wide right aligned column">
<p><?php echo $firstName . " " . $lastName ?></p>
</div>
</div>
<div class="row">
<div class="six wide left aligned column">
<h3><strong>Username</strong></h3>
</div>
<div class="ten wide right aligned column">
<p><?php echo $_SESSION['username']['username']; ?></p>
</div>
</div>
<div class="row">
<div class="six wide left aligned column">
<h3><strong>Password</strong></h3>
</div>
<div class="ten wide right aligned column">
<p>•••••••</p>
</div>
</div>
</div>
<!-- RENDER WHEN SHIPPING IS ACTIVE -->
<div id="shipping" class="ui grid">
<div class="row">
<div class="sixteen wide left aligned column">
<h2><strong>Shipping Addresses</strong></h2>
</div>
</div>
<div class="row">
<div class="six wide left aligned column">
<h3><strong>Primary Shipping</strong></h3>
</div>
<div class="ten wide right aligned column">
<p> <?php echo $address ?> <br>
<?php echo $city . ', ' . $state ?> <br>
<?php echo $zipcode ?>
</p>
</div>
</div>
</div>
<!-- RENDER WHEN PAYMENT IS ACTIVE -->
<div id="payment" class="ui grid">
<div class="row">
<div class="sixteen wide left aligned column">
<h2><strong>Payment Information</strong></h2>
</div>
</div>
<div class="row">
<div class="six wide left aligned column">
<h3><strong>Primary Payment</strong></h3>
</div>
<div class="ten wide right aligned column">
<p> <?php echo $firstName . " " . $lastName ?> <br>
<?php echo $card_type . " ending in " . $substring ?> <br>
<?php echo "Expiring on " . $expiration_date ?>
</p>
</div>
</div>
</div>
</div>
<!-- EDIT AND HOME BUTTONS -->
<div class="center aligned row">
<a href="home.php">
<button class="ui large animated fade blue button" tabindex="0">
<div class="hidden content"><i class="home icon"></i></div>
<div class="visible content">
<span class="text">Go home</span>
</div>
</button>
</a>
<a href="createProfile.php">
<button class="ui large animated fade gray button" tabindex="0">
<div class="hidden content"><i class="edit icon"></i></div>
<div class="visible content">
<span class="text">Edit info</span>
</div>
</button>
</a>
<button class="ui large animated fade red button" tabindex="0">
<div class="hidden content"><i class="trash alternate icon"></i></div>
<div class="visible content">
<span class="text">Delete account</span>
</div>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="ui mini modal">
<i class="close icon"></i>
<div class="header">
Delete Account
</div>
<div class="content">
<div class="description">
<p>Are you sure you want to delete your account?</p>
</div>
</div>
<form method="post" action="profile.php">
<div class="actions">
<div class="ui negative button">
No
</div>
<button class="ui positive right labeled icon button" name="delete">
Yes
<i class="checkmark icon"></i>
</button>
</div>
</form>
</div>
</section>
<script type="text/javascript">
$('.ui.green.menu')
.on('click', '.item', function() {
if(!$(this).hasClass('dropdown')) {
$(this)
.addClass('active')
.siblings('.item')
.removeClass('active');
}
});
$('.red').on('click', function() {
$('.ui.modal')
.modal('show')
;
});
$(document).ready(function() {
$('#account').show();
$('#shipping').hide();
$('#payment').hide();
});
$('#accountSection').on('click', function(){
$('#account').show();
$('#shipping').hide();
$('#payment').hide();
});
$('#shippingSection').on('click', function(){
$('#account').hide();
$('#shipping').show();
$('#payment').hide();
});
$('#paymentSection').on('click', function(){
$('#account').hide();
$('#shipping').hide();
$('#payment').show();
});
</script>
</body>
</html>