-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.php
executable file
·61 lines (53 loc) · 1.62 KB
/
header.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
// Things to notice:
// This script is called by every other script (via require_once)
// It begins the HTML output, with the customary tags, that will produce each of the pages on the web site
// It starts the session and displays a different set of menu links depending on whether the user is logged in or not...
// ... And, if they are logged in, whether or not they are the admin
// It also reads in the credentials for our database connection from credentials.php
// database connection details:
require_once "credentials.php";
// our helper functions:
require_once "helper.php";
// start/restart the session:
session_start();
if (isset($_SESSION['loggedInSkeleton']))
{
// THIS PERSON IS LOGGED IN
// show the logged in menu options:
echo <<<_END
<!DOCTYPE html>
<html>
<head><title>A Survey Website</title></head>
<body>
<a href='about.php'>About</a> ||
<a href='account.php'>My Account</a> ||
<a href='surveys_manage.php'>My Surveys</a> ||
<a href='competitors.php'>Design and Analysis</a> ||
<a href='sign_out.php'>Sign Out ({$_SESSION['username']})</a>
_END;
// add an extra menu option if this was the admin:
if ($_SESSION['username'] == "admin")
{
echo " |||| <a href='admin.php'>Admin Tools</a>";
//echo " |||| <a href='admin_surveys.php'>Admin Surveys</a>";
}
}
else
{
// THIS PERSON IS NOT LOGGED IN
// show the logged out menu options:
echo <<<_END
<!DOCTYPE html>
<html>
<body>
<a href='about.php'>About</a> ||
<a href='sign_up.php'>Sign Up</a> ||
<a href='sign_in.php'>Sign In</a>
_END;
}
echo <<<_END
<br>
<h1>2CWK50: A Survey Website</h1>
_END;
?>