-
Notifications
You must be signed in to change notification settings - Fork 0
/
editProfile.php
281 lines (232 loc) · 13.9 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
<?php include "includes/head.php"; ?>
<?php
if (!isset($_SESSION['errors']) || count($_SESSION['errors']) == 0) {
$_SESSION['errors'] = array();
}
$userID = $_SESSION['uID'];
$userName = $userEmail = $userContactNo = $userTitle = $userDescription = "";
$sql = "SELECT * FROM `tbl_users` WHERE `user_id` = '$userID' ";
$result = mysqli_query($con, $sql);
if(mysqli_num_rows($result)>0){
if($row = mysqli_fetch_assoc($result)){
$userName = $row['user_name'];
$userEmail= $row['user_email'];
$userContactNo = $row['user_contactNo'];
$userDescription = $row['user_description'];
$userTitle = $row['user_title'];
}
}else{
$_SESSION['errorMessage'] = "Something Going Wrong Please Try later.";
header("location:profile.php");
exit();
}
if(isset($_POST['submitbtn'])){
if(empty($_POST['userFullName'])){
array_push($_SESSION['errors'], "Name is required");
}else{
$userName = mysqli_real_escape_string($con, $_POST['userFullName']);
}
if(empty($_POST['userEmail'])){
array_push($_SESSION['errors'], "Email is required");
}else{
$userEmail = mysqli_real_escape_string($con, $_POST['userEmail']);
}
if(empty($_POST['userTitle'])){
array_push($_SESSION['errors'], "Profile Title is required");
}else{
$userTitle = mysqli_real_escape_string($con, $_POST['userTitle']);
}
$userContactNo = mysqli_real_escape_string($con, $_POST['userContactNo']);
$userDescription = mysqli_real_escape_string($con, $_POST['userDescription']);
// if( basename($_FILES["blogImage"]["name"] != "")){
// $target_dir = "../uploads/";
// $timestamp = time();
// $target_file = $target_dir . $timestamp.'-'.basename($_FILES["blogImage"]["name"]);
// $target_file_db = "uploads/" . $timestamp.'-'.basename($_FILES["blogImage"]["name"]);
// $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// $check = getimagesize($_FILES["blogImage"]["tmp_name"]);
// if($check !== false) {
// if (file_exists($target_file)) {
// array_push($_SESSION['errors'], "Sorry, file already exists");
// }
// //Check file size
// if ($_FILES["blogImage"]["size"] > 50000000000) {
// array_push($_SESSION['errors'], "File is too large");
// }
// if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) {
// array_push($_SESSION['errors'], "Sorry, only JPG, JPEG, PNG & GIF files are allowed.");
// }
// if (isset($_SESSION['errors']) && count($_SESSION['errors']) == 0) {
// if (move_uploaded_file($_FILES["blogImage"]["tmp_name"], $target_file)) {
// unlink($blogImage);
// $blogImage = $target_file_db;
// } else {
// array_push($_SESSION['errors'], "Sorry, there was an error uploading your file.");
// }
// }
// } else {
// array_push($_SESSION['errors'], "Please Upload Image File Only");
// }
// }else{
// $blogImage = $blogOldImage;
// }
// else{
// array_push($_SESSION['errors'], "Images is require");
// }
if (count($_SESSION['errors']) == 0 || !isset($_SESSION['errors'])) {
$sql = "UPDATE `tbl_users` SET `user_name` = '$userName', `user_email` = '$userEmail',`user_title` = '$userTitle', `user_contactNo` = '$userContactNo', `user_description` = '$userDescription' WHERE `user_id` = '$userID' ";
$result = mysqli_query($con,$sql);
if($result){
$_SESSION["successMessage"] = "Profile has been Updated";
header("location:profile.php");
exit();
}
}
}
// if(isset($_POST['submitbtn'])){
// }
?>
<body>
<?php include "includes/header.php"; ?>
<main class="site-main">
<!--================ Blog slider start =================-->
<!--================ Blog slider end =================-->
<!--================ Start Blog Post Area =================-->
<section class="blog-post-area section-margin mt-4">
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-8">
<?php
if (isset($_SESSION['errors']) && count($_SESSION['errors']) > 0) {
$errors = $_SESSION['errors'];
foreach($errors as $error){
?>
<div class="alert alert-danger ">
<?php echo $error; ?>
</div>
<?php
}
unset($_SESSION['errors']);
}
?>
<?php if(isset($_SESSION['successMessage'])){
?>
<div class="alert alert-success">
<?php echo $_SESSION['successMessage']; unset($_SESSION['successMessage']); ?>
</div>
<?php
} ?>
<form action="editProfile.php" method="post">
<div class="conteiner">
<div class="container mb-5 mt-3">
<h2 class=" mb-4 mt-3">Edit Profile</h2>
</div>
<!-- <div class="row"> -->
<div class="col mb-3">
<input type="text" placeholder="Enter Your Full Name" name="userFullName"
class="form-control" value="<?php echo $userName; ?>">
</div>
<div class="col mb-3">
<input type="email" placeholder="Enter Your Email Address" name="userEmail"
class="form-control" value="<?php echo $userEmail; ?>">
</div>
<div class="col mb-3">
<input type="text" placeholder="Enter Your Phone Number" name="userContactNo"
class="form-control" value="<?php if($userContactNo){echo $userContactNo;} ?>">
</div>
<div class="col mb-3">
<input type="text" placeholder="Profile Title (e.g Web Designer etc)" name="userTitle"
class="form-control" value="<?php echo $userTitle; ?>">
</div>
<div class="col mb-3">
<textarea name="userDescription" id="userDescription" cols="30" rows="10" placeholder="About" class="form-control" ><?php echo $userDescription; ?></textarea>
<!-- <input type="text" placeholder="Profile Title (e.g Web Designer etc)" name="usertitle"
class="form-control" value="<?php ?>"> -->
</div>
<div class="col mb-3">
<button class="btn btn-warning mt-4" name="submitbtn" type="submit">Save Profile</button>
</div>
</div>
<!-- </div> -->
</form>
<!-- <div class="page-content page-container" id="page-content">
<div class="padding">
<div class="row container d-flex justify-content-center">
<div class="col-xl-12 col-md-12">
<div class="card user-card-full">
<div class="row m-l-0 m-r-0">
<div class="col-sm-4 bg-c-lite-green user-profile">
<div class="card-block text-center text-white">
<div class="m-b-25">
<img src="https://img.icons8.com/bubbles/100/000000/user.png"
class="img-radius" alt="User-Profile-Image">
</div>
<h6 class="f-w-600"><?php echo $_SESSION['uFullName']; ?></h6>
<p>Web Designer</p>
<i
class=" mdi mdi-square-edit-outline feather icon-edit m-t-10 f-16"></i>
</div>
</div>
<div class="col-sm-8">
<div class="card-block">
<h6 class="m-b-20 p-b-5 b-b-default f-w-600">About</h6>
<div class="row">
<div class="col-sm-6">
<p class="m-b-10 f-w-600">Email</p>
<h6 class="text-muted f-w-400"><?php echo $_SESSION['uEmail']; ?></h6>
</div>
<div class="col-sm-6">
<p class="m-b-10 f-w-600">Phone</p>
<h6 class="text-muted f-w-400">98979989898</h6>
</div>
</div>
<h6 class="m-b-20 m-t-40 p-b-5 b-b-default f-w-600">Projects
</h6>
<div class="row">
<div class="col-sm-6">
<p class="m-b-10 f-w-600">Recent</p>
<h6 class="text-muted f-w-400">Sam Disuja</h6>
</div>
<div class="col-sm-6">
<p class="m-b-10 f-w-600">Most Viewed</p>
<h6 class="text-muted f-w-400">Dinoter husainm</h6>
</div>
</div>
<ul class="social-link list-unstyled m-t-40 m-b-10">
<li><a href="#!" data-toggle="tooltip"
data-placement="bottom" title=""
data-original-title="facebook" data-abc="true"><i
class="mdi mdi-facebook feather icon-facebook facebook"
aria-hidden="true"></i></a></li>
<li><a href="#!" data-toggle="tooltip"
data-placement="bottom" title=""
data-original-title="twitter" data-abc="true"><i
class="mdi mdi-twitter feather icon-twitter twitter"
aria-hidden="true"></i></a></li>
<li><a href="#!" data-toggle="tooltip"
data-placement="bottom" title=""
data-original-title="instagram" data-abc="true"><i
class="mdi mdi-instagram feather icon-instagram instagram"
aria-hidden="true"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="" class="btn btn-primary">Edit</a>
</div> -->
</div>
<!-- Start Blog Post Siddebar -->
<?php include "includes/sidebar.php"; ?>
<!-- End Blog Post Siddebar -->
</div>
</section>
<!--================ End Blog Post Area =================-->
</main>
<?php include "includes/footer.php"; ?>
<?php include "includes/jsfiles.php"; ?>
</body>
</html>