Загрузка данных


<?php 
session_start(); 
require 'db.php'; 

$msg = '';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $email = $_POST['email']; 
    $pass = $_POST['password'];
    
    // Ищем пользователя по email
    $stmt = $conn->prepare("SELECT * FROM users WHERE email = ?");
    $stmt->bind_param("s", $email); 
    $stmt->execute();
    $result = $stmt->get_result();
    $user = $result->fetch_assoc();
    
    // Проверяем пароль через хэш
    if ($user && password_verify($pass, $user['password'])) {
        $_SESSION['user_id'] = $user['id']; 
        $_SESSION['username'] = $user['username'];
        header("Location: index.php");
        exit();
    } else { 
        $msg = "Неверный email или пароль!"; 
    }
} 
?>

<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Вход в систему | TourBro</title>
</head>
<body class="auth-wrapper login-body">

    <div class="auth-card login-card-custom">
        <h2>С возвращением!</h2>
        
        <!-- Сообщение об ошибке -->
        <?php if($msg): ?>
            <div style="background: rgba(255, 71, 87, 0.1); color: #ff4757; padding: 10px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; font-weight: bold;">
                <?php echo $msg; ?>
            </div>
        <?php endif; ?>
        
        <form class="auth-form" method="POST">
            <!-- Первое поле (Email) -->
            <input type="email" name="email" class="login-input" placeholder="Ваш Email" required>
            
            <!-- Второе поле (Пароль) - теперь тоже со стилем login-input -->
            <input type="password" name="password" class="login-input" placeholder="Ваш Пароль" required>
            
            <!-- Кнопка входа -->
            <button type="submit" class="btn-primary btn-login-exclusive">Войти в аккаунт</button>
        </form>
        
        <div style="margin-top: 25px;">
            <a href="register.php" style="color: #6033ec; font-weight: bold; text-decoration: none; font-size: 14px;">Создать новый профиль</a>
        </div>
    </div>

</body>
</html>