-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
170 lines (141 loc) · 5.55 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
<?php
include ('config.php');
$_SESSION["id"] = 1;
$sessionId = $_SESSION["id"];
$user = mysqli_fetch_assoc(mysqli_query($conn,"SELECT * FROM profile WHERE id=$sessionId"));
?>
<!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>PXETube|Profile</title>
<!-- custom stylesheet -->
<link rel="stylesheet" href="assets/CSS/style.css">
<link rel="stylesheet" href="assets/CSS/stylehome.css">
<!-- font awesome cdn link -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
</head>
<body>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn " onclick="closeNav()">×</a>
<br><br><br>
<a href="home.php" class="links">
<i class="icon fa-solid fa-house"></i>Home</a>
<a href="your_videos.php" class="links">
<i class="icon fa-solid fa-tv"></i>Your Videos</a>
<a href="#" class="links">
<i class="icon fa-solid fa-gear"></i>Settings</a>
<a href="about.php" class="links">
<i class="icon fa-solid fa-circle-info"></i>About</a>
<a href="home.php?logout=<?php echo $user_id; ?>"
class="links">
<i class="icon fa-solid fa-power-off"></i>LogOut</a>
</div>
<nav class="navbar">
<div class="menu">
<span onclick="openNav()"><i class="fa-solid fa-bars"></i></span>
</div>
<a href="home.php"><img src="assets/images/logo.png" alt="logo" class="logo"></a>
<div class="search-box">
<input type="text" class="searchbar" name="search" placeholder="Search" id="">
<i class="fa-solid fa-magnifying-glass search"></i>
</div>
<div class="user-optn">
<a href="upload.php"><i class="fa-solid fa-video video"></i></a>
<a href="profile.php"> <i class="fa-solid fa-circle-user user"></i></a>
</div>
</nav>
<div class="contact">
<h3 >Your Profile!</h3>
</div>
<div class="row">
<form class="form" id="form" action="" enctype="multipart/form-data" method="post">
<div class="upload">
<?php
$id = $user["id"];
$name = $user["name"];
$image = $user['image'];
?>
<img src="profile/<?php echo $image; ?>" title="<?php echo $image; ?>" style="width: 380px;
height: 380px;" >
<div class="round">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="name" value="<?php echo $name; ?>">
<input type="file" name="image" id="image" accept=".jpg, .jpeg, .png">
<i class="fa fa-camera cam" ></i>
</div>
</div>
</form>
<!-- <div class="card">
<table class="table" style="margin-left: 40%;" >
<tr>
<th>Username</th>
<td>
$Username$
</td>
</tr>
<tr>
<th>Email</th>
<td>
$email$
</td>
</tr>
<tr>
<th>Joined on</th>
<td>
$signupdate$
</td>
</tr>
</table>
</div> -->
</div>
<script>
document.getElementById("image").onchange = function(){
document.getElementById('form').submit();
}
</script>
<?php
if (isset($_FILES['image']['name'])) {
$id = $_POST['id'];
$name = $_POST['name'];
$imageName = $_FILES['image']['name'];
$imageSize = $_FILES['image']['size'];
$tmpName = $_FILES['image']['tmp_name'];
$validImageExtension = ['jpg','jpeg','png'];
$imageExtension = explode('.',$imageName);
$imageExtension = strtolower(end($imageExtension));
if(!in_array($imageExtension,$validImageExtension)){
echo "
<script>
alret('Invalid Image Extension');
document.location.href = '../PXETube/profile.php';
</script>
" ;
}
elseif ($imageSize > 12000000) {
echo "
<script>
alert('Image Size is too Large');
document.location.href = '../PXETube/profile.php';
</script>
";
}
else {
$newImageName = $name . " - " . date("Y.m.d") . " - " . date("h.i.sa");
$newImageName .= "." . $imageExtension;
$query = "UPDATE profile SET image = '$newImageName' WHERE id = $id ";
mysqli_query($conn, $query);
move_uploaded_file($tmpName, 'profile/'.$newImageName);
echo "
<script>
document.location.href = '../PXETube/profile.php';
</script>
";
}
}
?>
<script src="assets/JS/script.js"></script>
</body>
</html>