|
1 | 1 | <?php
|
2 |
| -include_once "server.php"; |
3 |
| -session_start(); //start a new session if not already started |
4 |
| -if (!isset($_SESSION["username"])){ |
| 2 | + include_once "server.php"; |
| 3 | + session_start(); //start a new session if not already started |
| 4 | + $editable = false; |
| 5 | + if (isset($_GET['userID'])){ |
| 6 | + if ($_GET['userID'] != "") { |
| 7 | + if (isset($_SESSION["username"])) { |
| 8 | + if ($_SESSION["userID"] === $_GET['userID']) {//Check if the current signed-in user is the same as the user of the profile page |
| 9 | + $editable = true; //if the current signed-in user is the same as the user of the profile page, profile will be editable |
| 10 | + } |
| 11 | + } |
| 12 | + $profileID = $_GET['userID']; |
| 13 | + } |
| 14 | + else{//Else no userID in URL for profile page, redirect to homepage |
| 15 | + header('location: index.php'); |
| 16 | + } |
| 17 | + } |
| 18 | + |
| 19 | + else{//Else no userID in URL for profile page, redirect to homepage |
5 | 20 | header('location: index.php');
|
6 |
| -} |
7 |
| -include 'fetchProfile.php'; |
8 |
| -include 'updateProfile.php'; |
9 |
| -fetchProfile($_SESSION['email']); |
10 |
| -$memberSince = strtotime($_SESSION["time_created"]); |
| 21 | + } |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + include 'fetchProfile.php'; |
| 26 | + include 'updateProfile.php'; |
| 27 | + $profile = getProfilebyID($profileID); |
| 28 | + |
| 29 | + $memberSince = strtotime($profile["time_created"]); |
11 | 30 | ?>
|
12 | 31 |
|
13 | 32 |
|
|
198 | 217 | <div class="panel panel-default">
|
199 | 218 |
|
200 | 219 | <div class="panel-heading">
|
201 |
| - <img class="card-img-top" id="profilePic" src="data:image/jpeg;base64, <?php echo fetchProfilePic($_SESSION["username"]); ?>" alt="Profile Picture" style="width:75%; max-width: 300px; max-height: 300px;"> |
| 220 | + <img class="card-img-top" id="profilePic" src="data:image/jpeg;base64, <?php echo fetchProfilePic($profile["username"]); ?>" alt="Profile Picture" style="width:75%; max-width: 300px; max-height: 300px;"> |
202 | 221 | <div id="editImage" hidden>
|
203 | 222 | <div class="row justify-content-center" style="margin-top: 5px">
|
204 | 223 | <div class="col-sm-3"></div>
|
|
214 | 233 | </div>
|
215 | 234 | </div>
|
216 | 235 | <div id="username">
|
217 |
| - <h2><?php echo $_SESSION["username"]; ?></h2> |
| 236 | + <h2><?php echo $profile["username"]; ?></h2> |
218 | 237 | </div>
|
219 | 238 | <div style="display: none" id="usernameText" class="row justify-content-center">
|
220 | 239 | <div class="col-sm-4">
|
|
223 | 242 | <div class="col-sm-8">
|
224 | 243 |
|
225 | 244 | <textarea style="font-size: 18px; margin-top: 10px" id="newUsername" name="newUsername" class="form-control" rows="1"
|
226 |
| - ><?php echo $_SESSION["username"]; ?></textarea> |
| 245 | + ><?php echo $profile["username"]; ?></textarea> |
227 | 246 | </div>
|
228 | 247 | </div>
|
229 | 248 |
|
230 | 249 | </div>
|
231 | 250 | <div class="panel-body">
|
232 | 251 | <h4>About me:</h4>
|
233 |
| - <p id="aboutMe"> <?php echo $_SESSION["about"]; ?> </p> |
234 |
| - <textarea style="display: none; width: 80%" class="form-control" id="aboutText" name="aboutText" rows="3"><?php echo $_SESSION["about"]; ?></textarea> |
| 252 | + <p id="aboutMe"> <?php echo $profile["about"]; ?> </p> |
| 253 | + <textarea style="display: none; width: 80%" class="form-control" id="aboutText" name="aboutText" rows="3"><?php echo $profile["about"]; ?></textarea> |
235 | 254 | <div class="modal-footer"></div>
|
236 | 255 | <h4>Email:</h4>
|
237 |
| - <p> <?php echo $_SESSION["email"]; ?> </p> |
| 256 | + <p> <?php echo $profile["email"]; ?> </p> |
238 | 257 | <div class="modal-footer"></div>
|
239 | 258 | <h4>User ID:</h4>
|
240 |
| - <p> <?php echo $_SESSION["userID"]; ?> </p> |
| 259 | + <p> <?php echo $profile["userID"]; ?> </p> |
241 | 260 | <div class="modal-footer"></div>
|
242 | 261 | <h4 class="title">Registered Tech Hut User <span style="color: rgb(15, 184, 23)">✓</span></h4>
|
243 | 262 | <h4>Member Since:</h4>
|
244 | 263 | <p> <?php echo date('m/d/Y', $memberSince); ?> </p>
|
245 | 264 | </div>
|
246 |
| - <div class="panel-footer" > |
| 265 | + <div class="panel-footer" <?php if(!$editable) {echo "style=\"display:none;\"";} ?> > |
247 | 266 | <div class="row justify-content-center">
|
248 | 267 | <div class="col-sm-3"></div>
|
249 | 268 | <div class="col-sm-6">
|
|
0 commit comments