View sourcecode

The following files exists in this folder. Click to view.

home.php

65 lines ASCII Unix (LF)
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
<?php

include("check_session.php");

require_once(
"databaseconnection.php");

$sql "SELECT p.postId, p.headline, p.author, p.date, p.authorId FROM post p JOIN following f ON p.authorId = f.followedUserId WHERE f.userId = :userId ORDER BY p.postId DESC LIMIT 5";
$stmt $pdo->prepare($sql);
$stmt->execute(['userId' => $_SESSION["userId"]]);

$followedPosts $stmt->fetchAll(PDO::FETCH_ASSOC);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home</title>
    <link rel="stylesheet" href="/spectre/spectre-master/dist/spectre.css">
    <script src="https://kit.fontawesome.com/0b0c9a8dc7.js" crossorigin="anonymous"></script>
    <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=Special+Gothic+Expanded+One&family=Special+Gothic:wght@400..700&display=swap" rel="stylesheet">
    <style>
        #navTop{
            font-family: "Special Gothic Expanded One", Helvetica;
        }
    </style>
</head>
<body style="text-align: center;">
    <header class="navbar">
        <section class="navbar-section">
            <a href="settings.php" class="btn btn-link">Settings</a>
            <a href="#" class="btn btn-link">Home</a>
        </section>
        <section class="navbar-center">
            <h3 id="navTop">PHiNTERNET</h3>
        </section>
        <section class="navbar-section">
            <a href="newpost.php" class="btn btn-link">Create Post</a>
            <a href="profile.php?mess=<?php echo"{$_SESSION["userId"]}"?>" class="btn btn-link">Profile</a>
        </section>
    </header>
    <?php
    $outputName 
htmlspecialchars($_SESSION["name"]);
    echo
"<h1>Welcome {$outputName}!</h1><p>Your ID:{$_SESSION["userId"]}</p>";
    
?>
    <form method="post" action="search.php">
        <label>Search:</label><br>
        <input type="number" placeholder="Find people using their ID" id="search" name="searchId" style="width:20%; text-align: center;">
    </form>
    <br>
    <hr>
    <?php
    
    
for($i=0$i<=count($followedPosts)-1$i++){
        
$outputTitle=htmlspecialchars($followedPosts[$i]["headline"]);
        
$outputAuthor=htmlspecialchars($followedPosts[$i]["author"]);
        echo
"<p><a href=\"blogwatcher.php?mess={$followedPosts[$i]["postId"]}\" class=\"h2\">{$outputTitle}</a><br>Uploaded: {$followedPosts[$i]["date"]}<br>Author: $outputAuthor | {$followedPosts[$i]["authorId"]} </p>";
    }
    
    
?>
</body>
</html>