summaryrefslogtreecommitdiff
path: root/www/login.php
blob: 32077036e8071b6977547c27f08fbdd374013925 (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
<?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.
	
	$_GET["reason"] can have the following values:
	
		failure: Specifies that the username and password didn't match. The user is not logged in.
		
		database: Specifies that the request could not be fullfilled due to a database error. The user is not logged in.
		
		succuss: Specifies that the request was successfull. TODO should probably redirect to user root.
		
	$_GET["username"] contains the username if a prior attempt to login wasn't successfull.
	
	==================================================================================================================================================

*/
?>

<?php include("static/header.html");?>
	
	<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">
			<?php if(isset($_GET['reason']) && $_GET['reason'] == 'failure' && isset($_GET['username'])){
				echo '<h1 id="login-error"> Invalid username or password </h1>
				';
			}elseif(isset($_GET['reason']) && $_GET['reason'] == 'logout'){
				echo '<h1 id="logout-message"> Sucessfully logged out.</h1>
				';
			}elseif(isset($_GET['reason']) && $_GET['reason'] == 'database'){
				echo '<h1 id="login-error"> Internal Error. Please contact admin</h1>
				';
			}?>
		</div>
		<form id="login-form" method='post' action='/login'>
			<?php if(isset($_GET['reason']) && $_GET['reason'] == 'failure' && isset($_GET['username'])){
				echo '<input type="text" placeholder="username" name="username" id="username-input" class="login-input" value="'.$_GET['username'].'"required>
				';
			}else{
				echo '<input type="text" placeholder="username" name="username" id="username-input" class="login-input" 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>

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