denbooru-php/login.php

30 lines
1001 B
PHP

<?php
include("include/header.php");
$errorMsg = "";
$validUser = $_SESSION["login"] === true;
$hash = "$2y$10\$AEErDtoqRrizUSS.uIlkDOcX/w3mAxCDo28QnfSNg9FTMC8eQVpeC";
if(isset($_POST["sub"])) {
$validUser = $_POST["username"] == "admin" && password_verify($_POST["password"], $hash);
if(!$validUser) $errorMsg = "Invalid username or password.";
else $_SESSION["login"] = true;
}
if($validUser) {
header("Location: /index.php"); die();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>Login</title>
</head>
<body>
<form name="input" action="" method="post">
<label for="username">Username:</label><input type="text" value="<?= $_POST["username"] ?>" id="username" name="username" /><br/>
<label for="password">Password:</label><input type="password" value="" id="password" name="password" />
<div class="error"><?= $errorMsg ?></div>
<input type="submit" value="Home" name="sub" />
</form>
</body>
</html>