Initial setup, not working yet
This commit is contained in:
79
frontend/login.php
Normal file
79
frontend/login.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once "api/client.php";
|
||||
|
||||
$error = null;
|
||||
|
||||
if ($_POST) {
|
||||
|
||||
$response = api_request(
|
||||
"POST",
|
||||
"/auth/login",
|
||||
[
|
||||
"username" => $_POST["username"],
|
||||
"password" => $_POST["password"]
|
||||
]
|
||||
);
|
||||
|
||||
if ($response) {
|
||||
|
||||
setcookie(
|
||||
"token",
|
||||
$response,
|
||||
time() + 86400,
|
||||
"/"
|
||||
);
|
||||
|
||||
header("Location: items.php");
|
||||
exit;
|
||||
|
||||
} else {
|
||||
$error = "Invalid login";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Login</title>
|
||||
<link rel="stylesheet" href="assets/style.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<h1>Login</h1>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<p><?= $error ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="POST">
|
||||
|
||||
<input
|
||||
name="username"
|
||||
placeholder="Username"
|
||||
required
|
||||
>
|
||||
|
||||
<input
|
||||
name="password"
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
required
|
||||
>
|
||||
|
||||
<button type="submit">
|
||||
Login
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user