-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy patheditprofile.php
329 lines (325 loc) Β· 12.7 KB
/
editprofile.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
<?php
include "conn.php";
include "auth.php";
?>
<?php
$done = false;
if(isset($_GET['id']))
{
$id = $_GET['id'];
$sql = "SELECT * FROM `profile` WHERE `sn` = $id";
$result = mysqli_query($conn, $sql);
$data = mysqli_fetch_array($result);
}
else
{
$data['fn'] = NULL;
$data['ln'] = NULL;
$data['gender'] = NULL;
$data['dob'] = NULL;
$data['work'] = NULL;
$data['city'] = NULL;
$data['state'] = NULL;
$data['country'] = NULL;
$data['bio'] = NULL;
}
?>
<?php
if(isset($_POST['submit']))
{
$fn = $_POST['fn'];
$ln = $_POST['ln'];
$gender = $_POST['gender'];
$dob = $_POST['dob'];
$work = $_POST['work'];
$city = $_POST['city'];
$state = $_POST['state'];
$country = $_POST['country'];
$bio = $_POST['bio'];
if(isset($_GET['id']))
{
$sql = "UPDATE `profile` SET `fn` = '$fn', `ln` = '$ln', `gender` = '$gender', `dob` = '$dob', `work` = '$work', `city` = '$city', `state` = '$state', `country` = '$country', `bio` = '$bio' WHERE `profile`.`sn` = $id;";
$result = mysqli_query($conn, $sql);
if($result)
{
$done = true;
}
else
{
echo "Error in editing this note.";
}
}
else
{
$sql="INSERT INTO `profile` (`username`, `fn`, `ln`, `gender`, `dob`, `work`, `city`, `state`, `country`, `bio`, `date`)
VALUES ('$username', '$fn', '$ln', '$gender', '$dob', '$work', '$city', '$state', '$country', '$bio', current_timestamp());";
$result = mysqli_query($conn, $sql);
$sql = "SELECT * FROM `profile` WHERE `username` = '$username'";
$result = mysqli_query($conn, $sql);
$data = mysqli_fetch_array($result);
$done = true;
}
}
?>
<?php
$selectSql="SELECT * FROM `dp` WHERE `username` = '$username';";
$result = mysqli_query($conn, $selectSql);
$imgdata =mysqli_fetch_array($result);
if ($imgdata) {
$folder = $imgdata['folder'];
$sn = $imgdata['sn'];
}
else
{
$folder = "asset/user.png";
}
if(isset($_POST['upload']))
{
$fileName = $_FILES['userimg']['name'];
$fileType = $_FILES['userimg']['type'];
$fileTemp = $_FILES['userimg']['tmp_name'];
$fileSize = $_FILES['userimg']['size'];
$folder = "asset/$fileName";
move_uploaded_file($fileTemp, $folder);
if($fileSize==NULL)
{
echo '<div class="alert alert-danger" role="alert">
Select another image from gallary first.</div>';
if($imgdata) {
$folder = $imgdata['folder'];
}
else{
$folder = "asset/user.png";
}
}
else{
if($imgdata) {
unlink($imgdata['folder']);
$sql = "UPDATE `dp` SET `name` = '$fileName', `size` = '$fileSize', `folder` = '$folder' WHERE `dp`.`sn` = $sn;";
$result = mysqli_query($conn, $sql);
if($result)
{
echo "<div class='alert alert-success alert-dismissible fade show' role='alert'>
<strong>Success! </strong>Profile picture has been updated.
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>";
}
else{
echo "Profile picture has not been updated. ERROR!!!";
}
}
else{
$sql="INSERT INTO `dp` (`username`, `name`, `size`, `folder`, `date`) VALUES ('$username', '$fileName', '$fileSize', '$folder', current_timestamp());";
$result = mysqli_query($conn, $sql);
if($result)
{
echo "<div class='alert alert-success alert-dismissible fade show' role='alert'>
<strong>Success! </strong>Profile picture has been uploaded.
<button type='button' class='close' data-dismiss='alert' aria-label='Close'>
<span aria-hidden='true'>×</span>
</button>
</div>";
}
else{
echo "Profile picture has not been uploaded. ERROR!!!";
}
}
}
}
if($done)
{
header("Location: profile.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<title>Edit Profile | Namaste</title>
<link rel="icon" href="img/n.jpg" type="image/x-icon">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<style>
* {
font-family: 'Poppins', sans-serif;
}
h1,h2,h3,h4,h5,h6{
font-weight: bold;
}
body {
margin-top:20px;
color: #1a202c;
text-align: left;
background-color: #e2e8f0;
}
.card {
box-shadow: 0 1px 3px 0 rgba(0,0,0,.1), 0 1px 2px 0 rgba(0,0,0,.06);
}
.profile-img{
text-align: center;
}
.profile-img img{
width: 200px;
height: 210px;
}
.profile-img .file {
position: relative;
overflow: hidden;
margin-top: -68px;
height: 40px;
width: 200px;
border: none;
border-radius: 0;
font-size: 15px;
background: #212529b8;
}
.profile-img .file input {
position: absolute;
opacity: 0;
right: -80px;
top: 0;
}
.labels {
font-size: 14px;
font-weight:600;
}
.text-p
{
color: #0062cc;
font-weight:600;
}
.fa-check-circle{
position: absolute;
top: 60%;
right: 6%;
}
.card {
position: relative;
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border: 0 solid rgba(0,0,0,.125);
border-radius: .25rem;
}
.card-body {
flex: 1 1 auto;
min-height: 1px;
padding: 1rem;
}
.rounded-circle{
width: 180px;
height: 180px;
}
.gutters-sm {
margin-right: -8px;
margin-left: -8px;
}
.gutters-sm>.col, .gutters-sm>[class*=col-] {
padding-right: 8px;
padding-left: 8px;
}
.mb-3, .my-3 {
margin-bottom: 1rem!important;
}
.bg-gray-300 {
background-color: #e2e8f0;
}
.h-100 {
height: 100%!important;
}
.shadow-none {
box-shadow: none!important;
}
</style>
</head>
<body>
<div class="container">
<div class="main-body">
<nav aria-label="breadcrumb" class="main-breadcrumb">
<ol class="breadcrumb bg-white">
<li class="breadcrumb-item"><a href="home.php">Home</a></li>
<li class="breadcrumb-item"><a href="profile.php">Profile</a></li>
<li class="breadcrumb-item active" aria-current="page">Change Password</li>
</ol>
</nav>
<form method="POST" enctype="multipart/form-data">
<div class="row gutters-sm">
<div class="col-md-4 mb-3">
<div class="card h-100 pt-3">
<div class="card-body">
<div class="d-flex flex-column align-items-center text-center">
<div class="p-box col-md-4">
<div class="d-flex align-center justify-content-center">
<div class="profile-img">
<img src="<?php echo $folder;?>" alt="user"/>
<div class="file btn btn-lg btn-primary">
Change Photo
<input type="file" name="userimg"/>
</div>
</div>
</div>
</div>
<input type="submit" class="btn btn-primary" name="upload" value="Upload">
<p><small><small><i>*Click upload to see changes. <br> *Max allowed size is 1 MB.</i></small></small></p>
</div>
</div>
</div>
</div>
<div class="col-md-8">
<div class="card mb-3">
<div class="card-body p-4">
<div class="d-flex justify-content-between align-items-center">
<h4>Update Your Profile</h4>
</div>
<div class="row">
<div class="col-md-6 mt-2"><label class="labels">First Name</label><input type="text" name="fn" class="form-control" placeholder="First Name" value="<?php echo $data['fn'];?>"></div>
<div class="col-md-6 mt-2"><label class="labels">Last Name</label><input type="text" name="ln" class="form-control" placeholder="Last Name" value="<?php echo $data['ln'];?>"></div>
<div class="col-md-12 mt-2"><label class="labels">Username</label><input type="text" readonly class="form-control" value="<?php echo $_SESSION['username'];?>"> <i class="fa text-success fa-check-circle"></i></div>
</div>
<div class="row">
<div class="col-md-12 mt-2"><label class="labels">Gender</label></div>
<div class="col-md-12">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="gender" value="Male" checked>
<label class="form-check-label" for="Male">Male</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="gender" value="Female">
<label class="form-check-label" for="Female">Female</label>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 mt-2"><label class="labels">Date Of Birth</label><input type="date" name="dob" class="form-control" value="<?php echo $data['dob'];?>"></div>
<div class="col-md-12 mt-2"><label class="labels">Email</label><input type="text" readonly class="form-control" value="<?php echo $_SESSION['email'];?>"> <i class="fa text-success fa-check-circle"></i></div>
<div class="col-md-12 mt-2"><label class="labels">Mobile</label><input type="text" readonly class="form-control" value="<?php echo "+91 ".$_SESSION['mobile'];?>"> <i class="fa text-success fa-check-circle"></i></div>
<div class="col-md-12 mt-2"><label class="labels">Profession</label><input type="text" name="work" class="form-control" placeholder="Profession" value="<?php echo $data['work'];?>"></div>
<div class="col-md-12 mt-2"><label class="labels">Country</label><input type="text" name="country" class="form-control" placeholder="Country" value="<?php echo $data['country'];?>"></div>
<div class="col-md-6 mt-2"><label class="labels">State</label><input type="text" name="state" class="form-control" placeholder="State" value="<?php echo $data['state'];?>"></div>
<div class="col-md-6 mt-2"><label class="labels">City</label><input type="text" name="city" class="form-control" placeholder="City" value="<?php echo $data['city'];?>"></div>
<div class="col-md-12 mt-2"><label class="labels">Bio</label><textarea name="bio" class="form-control" rows="3"><?php echo $data['bio'];?></textarea></div>
</div>
<div class="mt-5 text-center">
<input type="submit" class="btn btn-success" value="Update" name="submit">
<input type="reset" class="btn btn-danger" value="Reset" name="submit">
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</body>
</html>