-
Notifications
You must be signed in to change notification settings - Fork 0
/
template_embedded.php
33 lines (32 loc) · 1.01 KB
/
template_embedded.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
<?php session_start();
include('..\connection.php'); ?>
<!doctype html> <!-- needs to have this, otherwise the bootstrap menu is distored a bit -->
<html>
<head>
<?php include('..\navbar.php'); ?>
<title>Client page</title>
</head>
<body>
<?php
// not logged in
if (!isset($_SESSION['user_id'])) {
// record the calling page
$_SESSION['initial_page'] = $_SERVER['PHP_SELF'];
// direct to login page
header("Location: ..\login.php");
} else {
// check the user's account has not been deleted in the meantime
$user_stmt = $dbh->prepare("SELECT * FROM `users` WHERE `id` = ?");
if ($user_stmt->execute([$_SESSION['user_id']]) && $user_stmt->rowCount() == 1) {
$user = $user_stmt->fetchObject();
// echo "<h1>" . $user->username . ", you are logged in.</h1>";
$user_stmt->closeCursor();
// put new programme codes here
} else {
echo "<h1>Your account does not exist!</h1>";
session_destroy();
}
} // if (!isset($_SESSION['user_id'])) {
?>
</body>
</html>