forked from tinymce/tinydrive-php-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
54 lines (46 loc) · 1.21 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
<?php
require('./config.php');
session_start();
$error = "";
if (isset($_POST["username"]) && isset($_POST["password"])) {
$loggedInUser = null;
foreach ($config["users"] as $user) {
if ($user["username"] === $_POST["username"] && $user["password"] === $_POST["password"]) {
$loggedInUser = $user;
break;
}
}
if ($loggedInUser) {
$_SESSION["user"] = $loggedInUser;
header('location: editor.php');
die();
} else {
$error = "Incorrect username or password.";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Login</title>
<link rel="stylesheet" href="assets/css/app.css">
</head>
<body>
<form method="post" action="index.php">
<?php if ($error !== "") { ?>
<div><?php echo $error; ?></div>
<?php } ?>
<p>Login with the user/passwords available in the config.php file</p>
<div>
<label for="username">User:</label>
<input type="text" id="username" name="username" value="johndoe">
</div>
<div>
<label for="password">Password:</label>
<input type="password" id="password" name="password" value="password">
</div>
<input type="submit" value="login">
</form>
</body>
</html>