1
0
This repository has been archived on 2025-05-29. You can view files and clone it, but cannot push or open issues or pull requests.
Random-Picture/admin/login.php

49 lines
1.3 KiB
PHP
Raw Normal View History

2025-04-14 16:50:30 +08:00
<?php
require_once __DIR__.'/../includes/auth.php';
if (isLoggedIn()) {
header("Location: admin.php");
exit;
}
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if (login($username, $password)) {
header("Location: admin.php");
exit;
} else {
$error = "用户名或密码错误";
}
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>后台登录</title>
<link rel="stylesheet" href="../assets/css/style.css">
</head>
<body>
<div class="login-container">
<div class="login-box">
<h2>图片管理系统</h2>
<?php if ($error): ?>
<div class="error-msg"><?= $error ?></div>
<?php endif; ?>
<form method="POST">
<div class="form-group">
<input type="text" name="username" placeholder="用户名" required>
</div>
<div class="form-group">
<input type="password" name="password" placeholder="密码" required>
</div>
<button type="submit">立即登录</button>
</form>
</div>
</div>
</body>
</html>