39233-vm/login.php
2026-03-18 06:44:17 +00:00

38 lines
1.4 KiB
PHP

<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// For now, hardcoded authentication
if ($_POST['username'] === 'user' && $_POST['password'] === 'user123') {
$_SESSION['is_logged_in'] = true;
header('Location: /');
exit;
} else {
$error = 'Invalid credentials';
}
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>登录 - 聊天系统</title>
<style>
body { font-family: sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: #f0f2f5; }
.login-box { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); width: 300px; }
input { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box;}
button { width: 100%; padding: 10px; background: #00a884; color: white; border: none; border-radius: 4px; cursor: pointer; }
</style>
</head>
<body>
<div class="login-box">
<h2>用户登录</h2>
<?php if (isset($error)) echo "<p style='color:red'>$error</p>"; ?>
<form method="post">
<input type="text" name="username" placeholder="账号" required>
<input type="password" name="password" placeholder="密码" required>
<button type="submit">登录</button>
</form>
</div>
</body>
</html>