first commit
This commit is contained in:
49
admin/login.php
Normal file
49
admin/login.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user