-
Notifications
You must be signed in to change notification settings - Fork 1
/
notifications.php
61 lines (60 loc) · 1.9 KB
/
notifications.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
<?php
session_start();
require 'config/config.php';
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true) {
header("location: login.php?redirect_link=notifications.php");
exit;
} else if (!isset($_GET['id'])) {
header('Location: index.php');
exit();
} else {
$id = $_GET['id'];
}
if ($_SESSION['admin'] == 0 && $_SESSION['id'] != $id) {
header("location: home.php");
return;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height">
<title>Notifications</title>
<link rel="shortcut icon" href="logos/logo.png" type="image/x-icon">
<link rel="stylesheet" href="css/notifications.css?v=<?php echo time(); ?>">
</head>
<body>
<?php require_once("header.php"); ?>
<div style="margin: 20px;">
<?php
$sql = "SELECT username FROM users WHERE id=$id";
$query1 = mysqli_query($link, $sql);
$row = mysqli_fetch_assoc($query1);
$user = $row['username'];
echo "<h1>$user's Notifications</h1>";
?>
<div class="main-div">
<?php
$sql = "SELECT * FROM notifications WHERE userid='$id' ORDER BY id DESC";
$result = mysqli_query($link, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$text = $row['text'];
$created_at = $row['created_at'];
echo "
<div class='secondary-div'>
<span>$text</span>
<span id='created_at'>$created_at</span>
</div>
";
}
} else {
echo "<div class='secondary-div'><span>No notifications!</span></div>";
}
?>
</div>
</div>
</body>
</html>