summaryrefslogtreecommitdiff
path: root/www/login.php
blob: 4d7ed6ba76906450c19139091498b154656de2fb (plain)
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
<?php
	/*
	Displays the login page and possible errors. Users can enter their username and password to login. TODO recover Password
	It has already been checked that the user isn't already logged in.
	
	$case can have the following values:
	
		LOGIN_PASSWORD: Specifies that the username and password didn't match. The user is not logged in.
		
		LOGIN_DATABASE: Specifies that the request could not be fullfilled due to a database error. The user is not logged in.
		
		LOGOUT_SUCCESSFULL: Specifies that user has been logged out.
		
	$_GET["username"] contains the username if a prior attempt to login wasn't successfull.
	
	==================================================================================================================================================

*/

function print_login($case){

	include("static/header.html");
	
	$username = isset($_POST['username']) ? $_POST['username'] : "";
	$message = "";

	switch($case){
		case(LOGIN_PASSWORD):
			$message = '<h1 id="login-error"> Invalid username or password </h1>
				';
			break;
		case(LOGIN_DATABASE):
			$message = '<h1 id="login-error"> Internal Error. Please contact admin</h1>
				';
			break;
		case(LOGOUT_SUCCESSFULL):
			$message = '<h1 id="logout-message"> Sucessfully logged out.</h1>
				';
			break;
	}
	
	echo '<link rel="stylesheet" type="text/css" href="/static/login.css">
	<div class="login-area">
		<h1 class="login-area"> Log in </h1>
		<div class="login-area" id="login-info-bar">'
		.$message.
		'</div>
		<form id="login-form" method="post" action="/login">
			<input type="text" placeholder="username" name="username" id="username-input" class="login-input" value="'. $username .'" required>
			<input type="password" placeholder="password" name="password" id="password-input" class="login-input" required>
			<input type="submit" name="login" id="button-input" class="login-input" value="login">
			<a href="recover-password.php" id="recover-password-link">recover password</a>
		</form>
	</div>';

	include("static/footer.html");
}
?>