38239-vm/login.php
2026-02-07 05:53:52 +00:00

102 lines
3.6 KiB
PHP

<?php
include_once 'config.php';
$error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? '';
if ($username && $password) {
$stmt = db()->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
$user = $stmt->fetch();
if ($user && password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['username'] = $user['username'];
header("Location: index.php");
exit;
} else {
$error = '用户名或密码错误';
}
} else {
$error = '请填写所有字段';
}
}
include 'header.php';
?>
<div class="auth-container d-flex align-items-center justify-content-center" style="min-height: 90vh; background: radial-gradient(circle at top right, #1e2329 0%, #0b0e11 100%);">
<div class="auth-card glass-card p-5" style="width: 100%; max-width: 450px; border-radius: 16px;">
<div class="text-center mb-5">
<div class="logo-circle mb-4 mx-auto">
<i class="bi bi-hexagon-fill text-warning display-4"></i>
</div>
<h2 class="fw-bold text-white">欢迎登录 <?php echo $project_name; ?></h2>
<p class="text-secondary">全球领先的加密资产交易平台</p>
</div>
<?php if ($error): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php endif; ?>
<form method="post">
<div class="mb-4">
<label class="form-label text-secondary small fw-bold">用户名</label>
<div class="input-group">
<span class="input-group-text bg-transparent border-secondary text-secondary">
<i class="bi bi-person"></i>
</span>
<input type="text" name="username" class="form-control bg-transparent text-white border-secondary" placeholder="请输入用户名" required>
</div>
</div>
<div class="mb-4">
<label class="form-label text-secondary small fw-bold">密码</label>
<div class="input-group">
<span class="input-group-text bg-transparent border-secondary text-secondary">
<i class="bi bi-lock"></i>
</span>
<input type="password" name="password" class="form-control bg-transparent text-white border-secondary" placeholder="请输入密码" required>
</div>
</div>
<button type="submit" class="btn btn-warning w-100 py-3 fw-bold shadow-lg mb-4">登录</button>
</form>
<div class="text-center">
<p class="text-secondary small">还没有账户? <a href="/register.php" class="text-warning text-decoration-none fw-bold">立即注册</a></p>
</div>
</div>
</div>
<style>
.auth-card {
border: 1px solid rgba(255, 255, 255, 0.1);
backdrop-filter: blur(20px);
}
.input-group-text {
border-right: none;
}
input.form-control {
border-left: none;
padding: 12px;
}
input.form-control:focus {
background: rgba(255, 255, 255, 0.05) !important;
box-shadow: none;
border-color: var(--accent-color);
}
.logo-circle {
width: 80px;
height: 80px;
background: rgba(240, 185, 11, 0.1);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
</style>
<?php include 'footer.php'; ?>