-
Notifications
You must be signed in to change notification settings - Fork 1
/
view.php
50 lines (36 loc) · 1.05 KB
/
view.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
<?php
$_TITLE = 'See post';
require('partials/header.php');
if(!$logged_in) {
header('Location: index.php');
}
if(!isset($_GET['p'])) {
header('Location: index.php');
}
$query_id = htmlspecialchars($_GET['p']);
// Preselect
$sql = "SELECT p.*,u.username FROM posts p INNER JOIN users u ON u.id = p.poster WHERE p.uuid = '$query_id'";
$stmt = $db->prepare($sql);
$stmt->execute();
$rows = $stmt->fetchColumn();
if($rows < 1) {
header('Location: index.php');
}
?>
<h1>See post</h1>
<p><a href="index.php">Return to index</a></p>
<?php
$stmt->execute();
foreach ($stmt as $row) {
$title = $row['title'];
$content = $row['content'];
$uuid = $row['uuid'];
$date = $row['post_date'];
$username = $row['username'];
$uuid = $row['uuid'];
print("<h2>$title</h2>");
print("<p>$content</p>");
print("On $date by <a href='u.php?u=$username'>$username</a> - $uuid");
}
require('partials/footer.php');
?>