-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
62 lines (60 loc) · 2.09 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
<!DOCTYPE html>
<?php
include('firebase.php');
include_once('includes.php');
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
session_start();
if(!isset($_SESSION["user"])){
$_SESSION["user"] = "invalid";
header("Location: index.php");
}
$user = stripper($_SESSION["user"]);
if($user == "invalid" || $user == "" || isset($_POST["logout"])) {
$_SESSION["user"] = "invalid";
header("Location: index.php");
}
?>
<html>
<head>
<link href="posting.css" rel="stylesheet">
<link href="general.css" rel="stylesheet">
</head>
<body>
<?php
include('navbar.php');
?>
<div class="content">
<?php
if(isSet($_POST["displayName"])){
$data = [
"displayName" => stripper($_POST["displayName"])
];
$firebase->update('Logins/' . $user , $data);
}
$userData = getUserData($firebase, $user);
?>
<form class="full-width py-2" action='profile.php' method='POST'>
<h3>Update Your Profile:</h3>
Display Name:<br/>
<input type="text" name="displayName" value="<?php echo readByKey("displayName", $userData, $user); ?>" />
<input class='btn btn-primary btn-sm btn-block' type='submit' name='update' value='Save'/>
</form>
<h3 class="full-width">Your Posts:</h3>
<div class="posting-container grid">
<?php
if(isset($_POST["remove"])) {
$num = preg_replace('/[^0-9]/', '', $_POST["whichpost"]);
removePost($firebase, $num, $user);
}
include("posting.php");
$posts = getAllPosts($firebase, $user);
postings($posts, $user, $firebase);
if(empty($posts)){
echo "You have no posts yet!<br>";
echo "Your posts will show up here";
}
?>
</div>
</div>
<body>
<html>