199 lines
5.9 KiB
PHP
199 lines
5.9 KiB
PHP
<?php
|
|||
|
|
// ============================================
|
||
|
|
// 文件: login.php
|
||
|
|
// 说明: 管理员登录页面
|
||
|
|
// ============================================
|
||
|
|
|
||
|
|
require_once 'config.php';
|
||
|
|
|
||
|
|
// 如果已登录,跳转到首页
|
||
|
|
if (isset($_SESSION['admin_id'])) {
|
||
|
|
header('Location: index.php');
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
$error = '';
|
||
|
|
|
||
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||
|
|
$username = trim($_POST['username'] ?? '');
|
||
|
|
$password = $_POST['password'] ?? '';
|
||
|
|
|
||
|
|
if (empty($username) || empty($password)) {
|
||
|
|
$error = '请输入用户名和密码';
|
||
|
|
} else {
|
||
|
|
$db = getDB();
|
||
|
|
$stmt = $db->prepare("SELECT * FROM admins WHERE username = ?");
|
||
|
|
$stmt->execute([$username]);
|
||
|
|
$admin = $stmt->fetch();
|
||
|
|
|
||
|
|
if ($admin && password_verify($password, $admin['password'])) {
|
||
|
|
$_SESSION['admin_id'] = $admin['id'];
|
||
|
|
$_SESSION['admin_username'] = $admin['username'];
|
||
|
|
header('Location: index.php');
|
||
|
|
exit;
|
||
|
|
} else {
|
||
|
|
$error = '用户名或密码错误';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
?>
|
||
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="zh-CN">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
|
<title>电影全纪录 - 登录</title>
|
||
|
|
<link rel="stylesheet" href="css/style.css">
|
||
|
|
<style>
|
||
|
|
/* 登录页专用样式 */
|
||
|
|
body {
|
||
|
|
display: flex;
|
||
|
|
justify-content: center;
|
||
|
|
align-items: center;
|
||
|
|
min-height: 100vh;
|
||
|
|
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
|
||
|
|
margin: 0;
|
||
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||
|
|
}
|
||
|
|
.login-container {
|
||
|
|
background: rgba(255,255,255,0.05);
|
||
|
|
backdrop-filter: blur(20px);
|
||
|
|
-webkit-backdrop-filter: blur(20px);
|
||
|
|
border: 1px solid rgba(255,255,255,0.1);
|
||
|
|
border-radius: 24px;
|
||
|
|
padding: 48px 40px;
|
||
|
|
width: 100%;
|
||
|
|
max-width: 400px;
|
||
|
|
box-shadow: 0 30px 80px rgba(0,0,0,0.5);
|
||
|
|
transition: transform 0.3s ease;
|
||
|
|
}
|
||
|
|
.login-container:hover {
|
||
|
|
transform: translateY(-4px);
|
||
|
|
}
|
||
|
|
.login-logo {
|
||
|
|
text-align: center;
|
||
|
|
margin-bottom: 36px;
|
||
|
|
}
|
||
|
|
.login-logo .icon {
|
||
|
|
font-size: 52px;
|
||
|
|
display: block;
|
||
|
|
margin-bottom: 8px;
|
||
|
|
}
|
||
|
|
.login-logo h1 {
|
||
|
|
color: #fff;
|
||
|
|
font-size: 28px;
|
||
|
|
font-weight: 700;
|
||
|
|
margin: 0;
|
||
|
|
letter-spacing: 2px;
|
||
|
|
}
|
||
|
|
.login-logo p {
|
||
|
|
color: rgba(255,255,255,0.5);
|
||
|
|
font-size: 14px;
|
||
|
|
margin: 6px 0 0;
|
||
|
|
}
|
||
|
|
.form-group {
|
||
|
|
margin-bottom: 20px;
|
||
|
|
}
|
||
|
|
.form-group label {
|
||
|
|
display: block;
|
||
|
|
color: rgba(255,255,255,0.7);
|
||
|
|
font-size: 14px;
|
||
|
|
font-weight: 500;
|
||
|
|
margin-bottom: 6px;
|
||
|
|
}
|
||
|
|
.form-group input {
|
||
|
|
width: 100%;
|
||
|
|
padding: 14px 18px;
|
||
|
|
background: rgba(255,255,255,0.08);
|
||
|
|
border: 1px solid rgba(255,255,255,0.12);
|
||
|
|
border-radius: 12px;
|
||
|
|
color: #fff;
|
||
|
|
font-size: 16px;
|
||
|
|
transition: all 0.3s ease;
|
||
|
|
box-sizing: border-box;
|
||
|
|
outline: none;
|
||
|
|
}
|
||
|
|
.form-group input:focus {
|
||
|
|
border-color: #e67e22;
|
||
|
|
background: rgba(255,255,255,0.12);
|
||
|
|
box-shadow: 0 0 0 4px rgba(230,126,34,0.15);
|
||
|
|
}
|
||
|
|
.form-group input::placeholder {
|
||
|
|
color: rgba(255,255,255,0.3);
|
||
|
|
}
|
||
|
|
.btn-login {
|
||
|
|
width: 100%;
|
||
|
|
padding: 14px;
|
||
|
|
background: linear-gradient(135deg, #e67e22, #f39c12);
|
||
|
|
border: none;
|
||
|
|
border-radius: 12px;
|
||
|
|
color: #fff;
|
||
|
|
font-size: 18px;
|
||
|
|
font-weight: 600;
|
||
|
|
cursor: pointer;
|
||
|
|
transition: all 0.3s ease;
|
||
|
|
margin-top: 8px;
|
||
|
|
letter-spacing: 1px;
|
||
|
|
}
|
||
|
|
.btn-login:hover {
|
||
|
|
transform: translateY(-2px);
|
||
|
|
box-shadow: 0 10px 30px rgba(230,126,34,0.3);
|
||
|
|
}
|
||
|
|
.btn-login:active {
|
||
|
|
transform: translateY(0);
|
||
|
|
}
|
||
|
|
.error-msg {
|
||
|
|
background: rgba(231,76,60,0.2);
|
||
|
|
border: 1px solid rgba(231,76,60,0.3);
|
||
|
|
color: #e74c3c;
|
||
|
|
padding: 12px 16px;
|
||
|
|
border-radius: 10px;
|
||
|
|
font-size: 14px;
|
||
|
|
margin-bottom: 16px;
|
||
|
|
text-align: center;
|
||
|
|
}
|
||
|
|
.login-footer {
|
||
|
|
text-align: center;
|
||
|
|
margin-top: 24px;
|
||
|
|
color: rgba(255,255,255,0.3);
|
||
|
|
font-size: 13px;
|
||
|
|
}
|
||
|
|
@media (max-width: 480px) {
|
||
|
|
.login-container {
|
||
|
|
padding: 32px 24px;
|
||
|
|
margin: 16px;
|
||
|
|
border-radius: 16px;
|
||
|
|
}
|
||
|
|
.login-logo h1 {
|
||
|
|
font-size: 24px;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div class="login-container">
|
||
|
|
<div class="login-logo">
|
||
|
|
<span class="icon">🎬</span>
|
||
|
|
<h1>电影全纪录</h1>
|
||
|
|
<p>记录每一帧感动</p>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<?php if ($error): ?>
|
||
|
|
<div class="error-msg"><?= h($error) ?></div>
|
||
|
|
<?php endif; ?>
|
||
|
|
|
||
|
|
<form method="POST" action="">
|
||
|
|
<div class="form-group">
|
||
|
|
<label>管理员账号</label>
|
||
|
|
<input type="text" name="username" placeholder="请输入用户名" value="<?= h($_POST['username'] ?? '') ?>" autofocus>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>密码</label>
|
||
|
|
<input type="password" name="password" placeholder="请输入密码">
|
||
|
|
</div>
|
||
|
|
<button type="submit" class="btn-login">登 录</button>
|
||
|
|
</form>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
</body>
|
||
|
|
</html>
|