File size: 3.5Kb
<?php
require_once 'db.php';
$errors = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$email = trim($_POST['email'] ?? '');
$password = $_POST['password'] ?? '';
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors[] = 'Введите корректный email';
}
if ($password === '') {
$errors[] = 'Введите пароль';
}
if (!$errors) {
$stmt = $mysqli->prepare("SELECT id, password_hash, is_banned FROM users WHERE email = ?");
$stmt->bind_param('s', $email);
$stmt->execute();
$stmt->bind_result($uid, $password_hash, $is_banned);
if ($stmt->fetch()) {
if ((int)$is_banned === 1) {
$errors[] = 'Ваш аккаунт заблокирован.';
} elseif (password_verify($password, $password_hash)) {
$_SESSION['user_id'] = $uid;
$stmt->close();
header('Location: index.php');
exit;
} else {
$errors[] = 'Неверный email или пароль';
}
} else {
$errors[] = 'Неверный email или пароль';
}
$stmt->close();
}
}
include 'header.php';
?>
<style>
.auth-page {
max-width:420px;
margin:20px auto 40px;
}
.auth-title {
font-size:26px;
font-weight:700;
margin-bottom:6px;
}
.auth-subtitle {
font-size:14px;
color:#7b7287;
margin-bottom:18px;
}
.auth-card {
background:#ffffff;
border-radius:22px;
padding:18px 18px 20px;
box-shadow:0 14px 40px rgba(0,0,0,0.08);
}
.auth-field {
margin-bottom:14px;
}
.auth-field label {
display:block;
font-size:13px;
margin-bottom:4px;
color:#6a5d76;
}
.auth-field input {
width:100%;
box-sizing:border-box;
}
.auth-error {
background:#ffe5eb;
color:#b3224a;
border-radius:14px;
padding:10px 12px;
font-size:13px;
margin-bottom:12px;
}
.auth-footer-text {
margin-top:12px;
font-size:13px;
color:#7b7287;
text-align:center;
}
.auth-footer-text a {
color:#ff4f8b;
text-decoration:none;
}
.auth-footer-text a:hover {
text-decoration:underline;
}
</style>
<div class="auth-page">
<div class="auth-title">С возвращением 👋</div>
<div class="auth-subtitle">Войдите, чтобы продолжить общение и смотреть новые совпадения.</div>
<div class="auth-card">
<?php if ($errors): ?>
<div class="auth-error">
<?php foreach ($errors as $e): ?>
<div><?= htmlspecialchars($e) ?></div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<form method="post">
<div class="auth-field">
<label for="email">Email</label>
<input id="email" type="email" name="email" required
value="<?= isset($email) ? htmlspecialchars($email) : '' ?>">
</div>
<div class="auth-field">
<label for="password">Пароль</label>
<input id="password" type="password" name="password" required>
</div>
<button type="submit" class="btn-primary" style="width:100%;margin-top:4px;">Войти</button>
</form>
<div class="auth-footer-text">
Нет аккаунта? <a href="register.php">Зарегистрироваться</a>
</div>
</div>
</div>
<?php include 'footer.php'; ?>