130 lines
3.4 KiB
PHP
130 lines
3.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
session_set_cookie_params(['path' => '/']);
|
|
session_start();
|
|
|
|
$error = null;
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$username = $_POST['username'] ?? '';
|
|
$password = $_POST['password'] ?? '';
|
|
|
|
// Dummy authentication
|
|
if ($username === 'admin' && $password === 'password') {
|
|
$_SESSION['user'] = ['name' => 'Admin'];
|
|
header('Location: dashboard.php');
|
|
exit;
|
|
} else {
|
|
$error = 'Invalid username or password';
|
|
}
|
|
}
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Login</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--bg-color-start: #6a11cb;
|
|
--bg-color-end: #2575fc;
|
|
--text-color: #ffffff;
|
|
--card-bg-color: rgba(255, 255, 255, 0.01);
|
|
--card-border-color: rgba(255, 255, 255, 0.1);
|
|
--input-bg-color: rgba(255, 255, 255, 0.1);
|
|
--input-border-color: rgba(255, 255, 255, 0.2);
|
|
--button-bg-color: #ffffff;
|
|
--button-text-color: #333;
|
|
}
|
|
body {
|
|
margin: 0;
|
|
font-family: 'Inter', sans-serif;
|
|
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
|
color: var(--text-color);
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
text-align: center;
|
|
}
|
|
main {
|
|
padding: 2rem;
|
|
}
|
|
.card {
|
|
background: var(--card-bg-color);
|
|
border: 1px solid var(--card-border-color);
|
|
border-radius: 16px;
|
|
padding: 2rem;
|
|
backdrop-filter: blur(20px);
|
|
-webkit-backdrop-filter: blur(20px);
|
|
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
|
width: 320px;
|
|
}
|
|
h1 {
|
|
font-size: 2rem;
|
|
font-weight: 700;
|
|
margin: 0 0 1.5rem;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 1rem;
|
|
text-align: left;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin-bottom: 0.5rem;
|
|
font-size: 0.9rem;
|
|
}
|
|
input {
|
|
width: 100%;
|
|
padding: 0.75rem;
|
|
background: var(--input-bg-color);
|
|
border: 1px solid var(--input-border-color);
|
|
border-radius: 8px;
|
|
color: var(--text-color);
|
|
font-size: 1rem;
|
|
box-sizing: border-box;
|
|
}
|
|
button {
|
|
width: 100%;
|
|
padding: 0.75rem;
|
|
background: var(--button-bg-color);
|
|
border: none;
|
|
border-radius: 8px;
|
|
color: var(--button-text-color);
|
|
font-size: 1rem;
|
|
font-weight: 700;
|
|
cursor: pointer;
|
|
margin-top: 1rem;
|
|
}
|
|
.error {
|
|
color: #ff8a80;
|
|
margin-top: 1rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<div class="card">
|
|
<h1>Login</h1>
|
|
<form method="POST" action="login.php">
|
|
<div class="form-group">
|
|
<label for="username">Username</label>
|
|
<input type="text" id="username" name="username" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">Password</label>
|
|
<input type="password" id="password" name="password" required>
|
|
</div>
|
|
<button type="submit">Login</button>
|
|
<?php if ($error): ?>
|
|
<p class="error"><?= htmlspecialchars($error) ?></p>
|
|
<?php endif; ?>
|
|
</form>
|
|
</div>
|
|
</main>
|
|
</body>
|
|
</html>
|