-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
191 lines (150 loc) · 5.15 KB
/
index.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
session_start();
include 'src/php/connectDB.php';
include 'src/php/signup.php';
include 'src/php/login.php';
include 'src/php/scoreboard.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="src/css/style.css">
<title>Memory</title>
</head>
<body>
<!-- CENTER BOX (GAME) -->
<div class="center-screen">
<div class="mainFrame" id="login">
<form action="" method="POST" autocomplete="off">
<!-- Content when not logged in -->
<div id="login">
<!-- INPUT FIELD -->
<label>
<input type="text" name="username" placeholder="Username" class="input" style="margin-bottom: 10px"><br>
<input type="password" name="password" placeholder="Password" class="input"
style="margin-bottom: 10px"><br>
</label>
<!-- SUBMIT BUTTON -->
<button type="submit" name="signup" class="button" style="width: 50%; float: left">Signup</button>
<button type="submit" name="login" class="button" style="width: 50%; float: right">Login</button>
</div>
</form>
<!-- SIGNUP AND LOGIN -->
<div class="fancyText1">
<?php
// SIGNUP
if (isset($_POST['signup'])) {
signup();
}
// LOGIN
if (isset($_POST['login'])) {
login();
}
// LOGOUT
if (isset($_POST['logout'])) {
session_start();
$_SESSION = array();
session_destroy();
}
// TOGGLE LOGIN BOX
//
// SIGNUP & LOGIN BOX
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] === false) {
?>
<style>
#logged {
display: none;
}
#login {
display: block;
}
</style>
<?php
}
//
// LOGGED IN BOX
if (isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true) {
?>
<style>
#login {
display: none;
}
#logged {
display: block;
}
</style>
<?php
}
//
?>
</div>
</div>
<div class="mainFrame" id="logged">
<!-- PREGAME INPUT -->
<div class="popup">
<form autocomplete="off">
<label>
<select id="mode">
<option value="pvp">PvP</option>
<option value="pvc">PvC</option>
</select>
<input type="text" id="cardCount" placeholder="Amount of cards" class="input">
<input type="text" id="copyCount" placeholder="Amount of copies" class="input">
<input type="text" id="player2" placeholder="Player two name" class="input">
</label>
</form>
<button class="play" id="play">Play</button>
</div>
<!-- CARD BOARD -->
<div class="grid">
</div>
</div>
</div>
<!-- TOP RIGHT BOX (LOGIN) -->
<div class="topright-screen">
<div class="mainFrame" style="min-width: 200px" id="logged">
<form action="" method="POST">
<!-- Content when logged in -->
<div style="flex-direction: column">
<!-- WELCOME MESSAGE -->
<h1 class="fancyText1" style="font-size: 24px">Welcome, <?= $_SESSION["username"] ?></h1>
<!-- LOGOUT BUTTON -->
<button type="submit" name="logout" class="button"
style="-ms-transform: translateX(42%); transform: translateX(42%)">Logout
</button>
</div>
</form>
</div>
</div>
<!-- TOP LEFT BOX (SCOREBOARD) -->
<div class="topleft-screen">
<div class="mainFrame" id="logged">
<!-- TITLE -->
<h1 class="fancyText1" style="font-size: 34px">SCOREBOARD</h1>
<!-- DATABASE ENTRIES -->
<div class="fancyText1">
<?php
// GETTING SCORES FROM DATABASE IN scoreboard.php
getScoresFromDB();
?>
</div>
</div>
</div>
<!-- TOP CENTER BOX (SCORE) -->
<div class="topcenter-screen">
<div class="mainFrame" id="logged">
<!-- DATA -->
<div class="data">
<div class="fancyText2" style="margin-right: 1em"><span class="scoreBoard_1"></span></div>
<div class="fancyText3"><span class="scoreBoard_2"></span></div>
</div>
<div class="fancyText2"><span class="scoreBoard_turn"></span></div>
</div>
</div>
<!-- JAVASCRIPT -->
<script src="src/js/initGame.js" type="module"></script>
</body>
</html>