-
Notifications
You must be signed in to change notification settings - Fork 1
/
user-details.php
122 lines (113 loc) · 3.53 KB
/
user-details.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
<?php
session_start();
include './partials/db.php';
if(!isset($_SESSION['username']) && ($_SESSION['user_id'] != true))
{
header("Location:forum.php"); //Do not allow access.
exit;}
if(isset($_POST['deleteacc'])){
$user_id=$_POST['deleteacc'];
$query="DELETE FROM `post` WHERE `user_id`=$user_id ";
$query2="DELETE FROM `comments` WHERE `author_id`=$user_id ";
$query3="DELETE FROM `users` WHERE `id`=$user_id ";
$res=$mysqli->query($query);
$res2=$mysqli->query($query2);
$res3=$mysqli->query($query3);
}
?>
<!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">
<title>CovidPort-User Profile</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom style sheet -->
<link rel="stylesheet" href="css/user.css?v=<?php echo time();?>">
</head>
<body>
<?php include './partials/header.php';?>
<div class="d-flex justify-content-between">
<div class="container main1">
<h3 class="mb-4">Details</h3>
<?php
$id=$_SESSION['user_id'];
$query="SELECT * FROM `users` WHERE `id` = $id";
$result=$mysqli->query($query);
if(mysqli_num_rows($result)>0){
while($data=$result->fetch_assoc()){
echo '<p>Name : '.$data['name'].'</p>';
echo '<p>Email : '.$data['email'].'</p>';
echo '<p>Mobile No : '.$data['mobile_no'].'</p>';
echo '<button type="button" class="btn btn-danger my-2" onclick="deleteacc('.$id.')">Delete Account</button>';
}
}
else{
echo '<p>No comments have been Made.</p>';
}
?>
</div>
<div class="container d-flex justify-content-between flex-column main">
<div class="posts">
<h3>Posts</h3>
<?php
$id=$_SESSION['user_id'];
$query="SELECT * FROM `post` WHERE `user_id` = '$id' ORDER BY `date_published` DESC";
$result=$mysqli->query($query);
if(mysqli_num_rows($result)>0){
while($data=$result->fetch_assoc()){
echo '<p><a href="post.php?id='.$data['post_id'].'">'.stripslashes($data['title']).'</a> in ' .$data['category'].'</p>';
}
}
else{
echo '<br><p>No Posts have been Made.</p>';
}
?>
</div>
<div class="comments">
<h3>Comments</h3>
<?php
$id=$_SESSION['user_id'];
$query="SELECT * FROM `comments` WHERE `author_id` = '$id' ORDER BY `date` DESC";
$result=$mysqli->query($query);
if(mysqli_num_rows($result)>0){
while($data=$result->fetch_assoc()){
echo '<p><a href="post.php?id='.$data['post_id'].'">'.$data['comment'].'</a></p>';
}
}
else{
echo '<br><p>No comments have been Made.</p>';
}
?>
</div>
</div>
</div>
<?php include './partials/footer.php';?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
function deleteacc(deleteid){
var con=confirm("Are you sure? All your data will be deleted");
if(con==true){
$.ajax({
url:"",
type:"post",
data:{deleteacc:deleteid},
success:function(data,status){
location.href = "login.php";
if(data == 'success')
return false;
}
});
}
}
</script>
</body>
</html>