-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry2.php
More file actions
86 lines (59 loc) · 2.11 KB
/
try2.php
File metadata and controls
86 lines (59 loc) · 2.11 KB
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
<?php
session_start();
if (!isset($_SESSION['user_id']) || !isset($_SESSION['username'])) {
header('Location: login.html');
exit;
}
require_once "phpfunctions/db_connect.php";
$user_id = $_SESSION['user_id'];
$username = $_SESSION['username'];
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
$email = $_SESSION['email'];
$phone = $_SESSION['phone'];
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php include 'navbar.php'; ?>
<div class="container">
<div class="left-sidebar">
<div class="imp-links">
<a href="account.php"><img src="images/User-image.png"> Account</a>
<a href="friends.php"><img src="images/friends.png"> Friends</a>
</div>
</div>
<!----------------- middle content--------- -->
<div class="main-content">
<h2>Your home screen, <?php echo $_SESSION['first_name']; ?></h2>
<?php
$userID = $_SESSION['user_id'];
$mydb = "StudentModule.db";
include "phpfunctions/getusersposts.php";
include "phpfunctions/getfriendsposts.php";
$userPosts = getUserPosts($userID, $mydb);
$friendsPosts = getFriendsPosts($userID, $mydb);
$allPosts = array_merge($userPosts, $friendsPosts);
usort($allPosts, function ($a, $b) {
return strtotime($b['post_date']) - strtotime($a['post_date']);
});
foreach ($allPosts as $post) {
echo '<div class="post">';
echo '<p>' . htmlspecialchars($post['post_text']) . '</p>';
echo '<p>Posted by: ' . ($post['username']) . '</p>';
echo '<p>Posted on: ' . ($post['post_date']) . '</p>';
echo '</div>';
}
?>
</div>
</div>
<div class="btm-navbar">
<a href="createpost.php" class="active">Make a new post</a>
</div>
</body>
</html>