-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
79 lines (79 loc) · 2.26 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
<?php
require_once("./includes/config_session.inc.php");
//session_start();
//session_regenerate_id();
require_once("./includes/register_view.inc.php");
require_once("./includes/login_view.inc.php");
require_once("./create/create_view.php");
require_once("./includes/dbh.inc.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./css/styles.css">
<title>Project view</title>
</head>
<body>
<div class="header">
<h3>
<?= serveUsername() ?>
</h3>
<?php
if(isset($_SESSION["user_id"])) { ?>
<form action="./includes/logout.inc.php">
<button id="logout">Logout</button>
</form>
<?php } ?>
</div>
<hr>
<?php
if(!isset($_SESSION["user_id"])) { ?>
<div class="block-containers">
<div class="register">
<h1>Register</h1>
<form action="includes/register.inc.php" method="POST" id="register-form">
<?php
serveRegisterInputs();
?>
<input type="submit" value="Register" class="register-input submit">
</form>
<?php
checkSignupErrors();
?>
</div>
<hr id="divider">
<div class="login">
<h1>Login</h1>
<form action="./includes/login.inc.php" method="POST" id="login-form">
<input type="text" name="username" placeholder="Username" class="login-input">
<br>
<input type="password" name="password" placeholder="Password" class="login-input">
<br>
<input type="submit" value="Login" class="login-input submit">
</form>
<?php
checkLoginErrors();
?>
</div>
</div>
<hr>
<?php } ?>
<?php
require_once("./mvc/db_model.php");
require_once("./mvc/db_contr.php");
$_SESSION["DB"] = getDatabase($pdo);
if(isset($_GET["id"]))
{
$_SESSION["tmpP"] = getProjectByID($pdo, $_GET["id"]);
$_SESSION["tmpE"] = getUserEmail($pdo, $_SESSION["tmpP"]["uid"]);
invokeSingletonView();
}
else
{
invokeDBView();
}
?>
</body>
</html>