-
Notifications
You must be signed in to change notification settings - Fork 1
/
profile.php
369 lines (289 loc) · 9.57 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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<!DOCTYPE html>
<?php
session_start();
include("includes/header.php");
if(!isset($_SESSION['user_email'])){
header("location: index.php");
}
?>
<html>
<head>
<?php
$user = $_SESSION['user_email'];
$get_user = "select * from users where user_email='$user'";
$run_user = mysqli_query($con,$get_user);
$row = mysqli_fetch_array($run_user);
$user_name = $row['user_name'];
?>
<title><?php echo "$user_name"; ?></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="style/home_style2.css">
</head>
<style>
#cover-img{
height: 400px;
width: 100%;
}#profile-img{
position: absolute;
top: 160px;
left: 40px;
}
#update_profile{
position: relative;
top: -33px;
cursor: pointer;
left: 93px;
border-radius: 4px;
background-color: rgba(0,0,0,0.1);
transform: translate(-50%, -50%);
}
#button_profile{
position: absolute;
top: 82%;
left: 50%;
cursor: pointer;
transform: translate(-50%, -50%);
}
#own_posts{
border: 5px solid #e6e6e6;
padding 40px 50px;
}
#post_img{
height: 300px;
width:100%;
}
</style>
<body>
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-8">
<?php
echo"
<div>
<div><img id='cover-img' class='img-rounded' src='cover/$user_cover' alt='cover'></div>
<form action='profile.php?u_id=$user_id' method='post' enctype='multipart/form-data'>
<ul class='nav pull-left' style='position:absolute;top:10px;left:40px;'>
<li class='dropdown'>
<button class='dropdown-toggle btn btn-default' data-toggle='dropdown'>Change Cover</button>
<div class='dropdown-menu'>
<center>
<p>Click <strong>Select Cover</strong> and then click the <br> <strong>Update Cover</strong></p>
<label class='btn btn-info'> Select Cover
<input type='file' name='u_cover' size='60' />
</label><br><br>
<button name='submit' class='btn btn-info'>Update Cover</button>
</center>
</div>
</li>
</ul>
</form>
</div>
<div id='profile-img'>
<img src='users/$user_image' alt='Profile' class='img-circle' width='180px' height='185px'>
<form action='profile.php?u_id='$user_id' method='post' enctype='multipart/form-data'>
<label id='update_profile'> Select Profile
<input type='file' name='u_image' size='60' />
</label><br><br>
<button id='button_profile' name='update' class='btn btn-info'>Update Profile</button>
</form>
</div><br>
";
?>
<?php
if(isset($_POST['submit'])){
$u_cover = $_FILES['u_cover']['name'];
$image_tmp = $_FILES['u_cover']['tmp_name'];
$random_number = rand(1,100);
if($u_cover==''){
echo "<script>alert('Please Select Cover Image')</script>";
echo "<script>window.open('profile.php?u_id=$user_id' , '_self')</script>";
exit();
}else{
move_uploaded_file($image_tmp, "cover/$u_cover.$random_number");
$update = "update users set user_cover='$u_cover.$random_number' where user_id='$user_id'";
$run = mysqli_query($con, $update);
if($run){
echo "<script>alert('Your Cover Updated')</script>";
echo "<script>window.open('profile.php?u_id=$user_id' , '_self')</script>";
}
}
}
?>
</div>
<?php
if(isset($_POST['update'])){
$u_image = $_FILES['u_image']['name'];
$image_tmp = $_FILES['u_image']['tmp_name'];
$random_number = rand(1,100);
if($u_image==''){
echo "<script>alert('Please Select Profile Image on clicking on your profile image')</script>";
echo "<script>window.open('profile.php?u_id=$user_id' , '_self')</script>";
exit();
}else{
move_uploaded_file($image_tmp, "users/$u_image.$random_number");
$update = "update users set user_image='$u_image.$random_number' where user_id='$user_id'";
$run = mysqli_query($con, $update);
if($run){
echo "<script>alert('Your Profile Updated')</script>";
echo "<script>window.open('profile.php?u_id=$user_id' , '_self')</script>";
}
}
}
?>
<div class="col-sm-2">
</div>
</div>
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-2" style="background-color: #e6e6e6;text-align: center;left: 0.8%;border-radius: 5px;">
<?php
echo"
<center><h2><strong>About</strong></h2></center>
<center><h4><strong>$first_name $last_name</strong></h4></center>
<p><strong><i style='color:grey;'>$describe_user</i></strong></p><br>
<p><strong>Semester: </strong> $sem</p><br>
<p><strong>Branch: </strong> $user_branch</p><br>
<p><strong>Member Since: </strong> $register_date</p><br>
<p><strong>Gender: </strong> $user_gender</p><br>
<p><strong>Date of Birth: </strong> $user_birthday</p><br>
";
?>
</div>
<div class="col-sm-6">
<?php
global $con;
if(isset($_GET['u_id'])){
$u_id = $_GET['u_id'];
}
$get_posts = "select * from posts where user_id='$u_id' ORDER by 1 DESC LIMIT 5";
$run_posts = mysqli_query($con,$get_posts);
while($row_posts =mysqli_fetch_array($run_posts)){
$post_id =$row_posts['post_id'];
$user_id =$row_posts['user_id'];
$content =$row_posts['post_content'];
$upload_image =$row_posts['upload_image'];
$post_date =$row_posts['post_date'];
$user= "select * from users where user_id ='$user_id' AND posts='yes'";
$run_user =mysqli_query($con,$user);
$row_user =mysqli_fetch_array($run_user);
$user_name=$row_user['user_name'];
$user_image=$row_user['user_image'];
if($content == "No" && strlen($upload_image)>=1){
echo"
<div id='own_posts'>
<div class ='row'>
<div class='col-sm-2'>
<p> <img src ='users/$user_image' class='img-circle' width ='100px' height='100px'></p>
</div>
<div class='col-sm-6'>
<h3> <a style='text-decoration: none; cursor:pointer; color #3897f0;'
href='user_profile.php?u_id=$user_id'>$user_name</a></h3>
<h4><small style ='color: black;'>Updated a post on <strong>$post_date</strong></small></h4>
</div>
<div class ='col-sm-4'>
</div>
</div>
<div class='row'>
<div class ='col-sm-12'>
<img id='posts-img' src='imagepost/$upload_image' style='height:350px;'>
</div>
</div>
<a href='single.php?post_id=$post_id' style='float:right;'><button class='btn btn-success'>View</button></a>
<a href ='functions/delete_post.php?post_id=$post_id'
style='float:right;'><button class='btn btn-danger'>
Delete</button></a>
</div><br><br>
";
}else if(strlen($content)>=1 && strlen($upload_image)>=1){
echo"
<div id='own_posts'>
<div class ='row'>
<div class='col-sm-2'>
<p> <img src ='users/$user_image' class='img-circle' width ='100px' height='100px'></p>
</div>
<div class='col-sm-6'>
<h3> <a style='text-decoration: none; cursor:pointer; color #3897f0;'
href='user_profile.php?u_id=$user_id'>$user_name</a></h3>
<h4><small style ='color: black;'>Updated a post on <strong> $post_date</strong></small></h4>
</div>
<div class ='col-sm-4'>
</div>
</div>
<div class='row'>
<div class ='col-sm-12'>
<h3> <p>$content</p></h3>
<img id='posts-img' src='imagepost/$upload_image' style='height:350px;'>
</div>
</div>
<a href='single.php?post_id=$post_id' style='float:right;'><button class='btn btn-success'>View</button></a>
<a href ='functions/delete_post.php?post_id=$post_id'
style='float:right;'><button class='btn btn-danger'>
Delete</button></a>
</div><br><br>
";
}
else{
echo"
<div id='own_posts'>
<div class ='row'>
<div class='col-sm-2'>
<p> <img src ='users/$user_image' class='img-circle' width ='100px' height='100px'></p>
</div>
<div class='col-sm-6'>
<h3> <a style='text-decoration: none; cursor:pointer; color #3897f0;'
href='user_profile.php?u_id=$user_id'>$user_name</a></h3>
<h4><small style ='color: black;'>Updated a post on <strong> $post_date</strong></small></h4>
</div>
<div class ='col-sm-4'>
</div>
</div>
<div class='row'>
<div class ='col-sm-6'>
<h3> <p>$content</p> </h3>
</div>
<div class='col-sm-4'>
</div>
</div>
";
global $con;
if(isset($_GET['u_id'])){
$u_id =$_GET['u_id'];
}
$get_posts = "select user_email from users where user_id='$u_id'";
$run_user= mysqli_query($con,$get_posts);
$row=mysqli_fetch_array($run_user);
$user_email=$row['user_email'];
$user =$_SESSION['user_email'];
$get_user ="select * from users where user_email='$user'";
$run_user =mysqli_query($con,$get_user);
$row =mysqli_fetch_array($run_user);
$user_id =$row['user_id'];
$u_email =$row['user_email'];
if($u_email !=$user_email){
echo "<script> window.open('profile.php?u_id=$user_id','_self')</script>";
}else{
echo"
<a href='single.php?post_id=$post_id' style='float:right;'><button class='btn btn-success'>View</button></a>
<a href='edit_post.php?post_id=$post_id' style='float:right;'><button class='btn btn-info'>Edit</button></a>
<a href ='functions/delete_post.php?post_id=$post_id'
style='float:right;'><button class='btn btn-danger'>
Delete</button></a>
</div><br><br><br>
";
}
}
include("functions/delete_post.php");
}
?>
</div>
<div class='col-sm-2'>
</div>
</div>
</body>
</html>