/
header.php
105 lines (95 loc) · 2.44 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
function genHeader($selectedPage)
{
genUserBar();
genNavBar($selectedPage);
}
function genUserBar()
{
if(loggedIn())
{
?>
<!--including script here bad? where should we then?-->
<script src="js/user.js"></script>
<div id = "loginDiv">
<div id = "innerLoginDiv">
Welcome <?php echo getLoggedInUsername() ?>!
<button id = 'buttonMyBooks' onClick="document.location.href='mybooks.php'">My Books</button>
<button id = 'buttonLogout' onclick = "logout()"> Logout </button>
</div>
</div>
<?php
}
else
{
?>
<!--including script here bad? where should we then?-->
<script src="js/user.js"></script>
<!--TODO: build css file for this-->
<div id = "loginDiv">
<div id = "innerLoginDiv">
Username:
<input id = 'usernameInput' type='text' maxlength='30' value=''/>
Password:
<input id = 'passwordInput' type='password' maxlength='30' value=''/>
<button id = 'buttonLogin' onclick='login()'> Login </button>
<form id = "signUpForm" action="signup.php">
<input type="submit" value="Sign Up">
</form>
</div>
</div>
<?php
}
}
function genNavBar($selectedPage)
{
switch ($selectedPage)
{
case 'index':
?>
<div id='cssmenu'>
<ul>
<li class='active'><a href='index.php'><span>Home</span></a></li>
<li><a href='categories.php'><span>Books</span></a></li>
<li><a href='upload.php'><span>Upload a Book</span></a></li>
</ul>
</div>
<?php
break;
case 'categories':
?>
<div id='cssmenu'>
<ul>
<li><a href='index.php'><span>Home</span></a></li>
<li class='active'><a href='categories.php'><span>Books</span></a></li>
<li><a href='upload.php'><span>Upload a Book</span></a></li>
</ul>
</div>
<?php
break;
case 'upload':
?>
<div id='cssmenu'>
<ul>
<li><a href='index.php'><span>Home</span></a></li>
<li><a href='categories.php'><span>Books</span></a></li>
<li class='active'><a href='upload.php'><span>Upload a Book</span></a></li>
</ul>
</div>
<?php
break;
default:
?>
<div id='cssmenu'>
<ul>
<li><a href='index.php'><span>Home</span></a></li>
<li><a href='categories.php'><span>Books</span></a></li>
<li><a href='upload.php'><span>Upload a Book</span></a></li>
</ul>
</div>
<?php
break;
}
}
require 'userFunctions.php'
?>