38916-vm/register.php
Flatlogic Bot fd8a2de90a z
2026-03-01 18:23:38 +00:00

57 lines
2.0 KiB
PHP

<?php
require_once __DIR__ . '/auth.php';
if (isset($_SESSION['user_id'])) {
header('Location: index.php');
exit;
}
$error = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$res = register($_POST['username'], $_POST['password']);
if (!empty($res['success'])) {
login($_POST['username'], $_POST['password']);
header('Location: index.php');
exit;
}
$error = $res['error'] ?? 'Неизвестная ошибка';
}
?>
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Регистрация - Система поддержки</title>
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
</head>
<body class="auth-page">
<div class="bg-animations">
<div class="blob blob-1"></div>
<div class="blob blob-2"></div>
<div class="blob blob-3"></div>
</div>
<div class="main-wrapper">
<div class="auth-card">
<h2>Регистрация</h2>
<?php if ($error): ?>
<div class="alert alert-error"><?= htmlspecialchars($error) ?></div>
<?php endif; ?>
<form method="POST">
<div class="form-group">
<label for="username">Имя пользователя</label>
<input type="text" name="username" id="username" required autocomplete="username">
</div>
<div class="form-group">
<label for="password">Пароль</label>
<input type="password" name="password" id="password" required autocomplete="new-password">
</div>
<button type="submit" class="btn-primary">Зарегистрироваться</button>
</form>
<p class="auth-footer">Уже есть аккаунт? <a href="login.php">Войти</a></p>
</div>
</div>
</body>
</html>