-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.php
90 lines (68 loc) · 1.5 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
<?php
$loggedIn = false;
$error = '';
if ( $_POST ) {
if ( empty($_POST['username']) && empty($_POST['password']) ) {
$error = 'Username and Password is empty';
} else if ( !empty($_POST['username']) && empty($_POST['password']) ) {
$error = 'Password is empty';
} else if ( empty($_POST['username']) && !empty($_POST['password']) ) {
$error = 'Username is empty';
} else {
if ( $_POST['username'] == 'testing' && $_POST['password'] == 'test' ) {
$loggedIn = true;
} else {
$error = 'Invalid Username and/or Password';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Login Demo</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
<?php
if ( $loggedIn ) {
?>
<h1>Dashobard</h1>
<?php
} else {
?>
<form method="POST" action="">
<fieldset>
<legend>Login</legend>
<?php
if ( $error ) {
?>
<div class="error">
<?php echo $error ?>
</div>
<?php
}
?>
<div>
<label for="username">Username</label>
<input type="text" name="username" id="username" />
</div>
<div>
<label for="password">Password</label>
<input type="password" name="password" id="password" />
</div>
<div>
<input type="submit" value="Log In" />
</div>
</fieldset>
</form>
<?php
}
?>
</div>
</body>
</html>