-
Notifications
You must be signed in to change notification settings - Fork 39
/
view.php
50 lines (40 loc) · 1.24 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
require_once 'connect.php';
require_once 'header.php';
$id = (INT)$_GET['id'];
if ($id < 1) {
header("location: $url_path");
}
$sql = "Select * FROM posts WHERE id = '$id'";
$result = mysqli_query($dbcon, $sql);
$invalid = mysqli_num_rows($result);
if ($invalid == 0) {
header("location: $url_path");
}
$hsql = "SELECT * FROM posts WHERE id = '$id'";
$res = mysqli_query($dbcon, $hsql);
$row = mysqli_fetch_assoc($result);
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
$author = $row['posted_by'];
$time = $row['date'];
echo '<div class="w3-container w3-sand w3-card-4">';
echo "<h3>$title</h3>";
echo '<div class="w3-panel w3-leftbar w3-rightbar w3-border w3-sand w3-card-4">';
echo "$description<br>";
echo '<div class="w3-text-grey">';
echo "Posted by: " . $author . "<br>";
echo "$time</div>";
?>
<?php
if (isset($_SESSION['username'])) {
?>
<div class="w3-text-green"><a href="<?=$url_path?>edit.php?id=<?php echo $row['id']; ?>">[Edit]</a></div>
<div class="w3-text-red">
<a href="<?=$url_path?>del.php?id=<?php echo $row['id']; ?>"
onclick="return confirm('Are you sure you want to delete this post?'); ">[Delete]</a></div>
<?php
}
echo '</div></div>';
include("footer.php");