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


/* Контейнер для фиксации высоты и предотвращения скачков */
.auth-card {
    position: relative;
    overflow: hidden;
    min-height: 500px; /* Настройте под свой контент */
}

.auth-view {
    display: none; /* Скрыто по умолчанию */
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.4s ease;
}

.auth-view.active {
    display: block;
    opacity: 1;
    transform: translateX(0);
}

/* Стили для ссылок переключения */
.switch-text {
    margin-top: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: #888;
}

.switch-text a {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    border-bottom: 1px solid transparent;
    transition: 0.3s;
}

.switch-text a:hover {
    border-bottom-color: #fff;









<!-- Измените содержимое внутри <div class="auth-card"> -->
<div class="auth-card">
    <!-- Кнопка закрытия возвращает на предыдущую страницу -->
    <button class="close-btn" onclick="window.history.length > 1 ? history.back() : window.location.href='index.php'">&times;</button>

    <!-- Заголовок будет меняться через JS -->
    <h2 id="auth-title">Регистрация</h2>

    <!-- Контейнер для переключения видов -->
    <div id="auth-container">
        
        <!-- БЛОК РЕГИСТРАЦИИ -->
        <div id="view-register" class="auth-view active">
            <div class="type-toggle">
                <button type="button" class="type-btn active" id="btn-private">Частное лицо</button>
                <button type="button" class="type-btn" id="btn-company">Компания</button>
            </div>

            <form action="vendor/signup.php" method="POST" id="reg-form">
                <input type="hidden" name="user_type" id="user-type" value="private">
                <div class="form-group">
                    <label id="label-name">ФИО</label>
                    <input type="text" name="display_name" required placeholder="Введите данные">
                </div>
                <div class="form-group">
                    <label>Номер телефона</label>
                    <input type="tel" name="phone" required placeholder="+7 (___) ___-__-__">
                </div>
                <div class="form-group">
                    <label>Электронная почта</label>
                    <input type="email" name="email" required placeholder="example@axioma.ru">
                </div>
                <div class="form-group">
                    <label>Пароль</label>
                    <input type="password" name="password" id="password" required>
                </div>
                <div class="form-group checkbox-group">
                    <input type="checkbox" id="terms" required>
                    <label for="terms">Я согласен с <a href="#">политикой конфиденциальности</a></label>
                </div>
                <button type="submit" class="reg-button">Создать профиль</button>
            </form>
            <p class="switch-text">Уже есть аккаунт? <a href="javascript:void(0)" onclick="toggleAuth('login')">Войти</a></p>
        </div>

        <!-- БЛОК ВХОДА -->
        <div id="view-login" class="auth-view">
            <form action="vendor/signin.php" method="POST" id="login-form">
                <div class="form-group">
                    <label>Электронная почта</label>
                    <input type="email" name="email" required placeholder="example@axioma.ru">
                </div>
                <div class="form-group">
                    <label>Пароль</label>
                    <input type="password" name="password" required>
                </div>
                <button type="submit" class="reg-button">Войти в аккаунт</button>
            </form>
            <p class="switch-text">Нет аккаунта? <a href="javascript:void(0)" onclick="toggleAuth('register')">Зарегистрироваться</a></p>
        </div>

    </div>
</div>








function toggleAuth(mode) {
    const regView = document.getElementById('view-register');
    const loginView = document.getElementById('view-login');
    const title = document.getElementById('auth-title');

    if (mode === 'login') {
        regView.classList.remove('active');
        setTimeout(() => {
            regView.style.display = 'none';
            loginView.style.display = 'block';
            setTimeout(() => loginView.classList.add('active'), 50);
            title.innerText = 'Вход';
        }, 400);
    } else {
        loginView.classList.remove('active');
        setTimeout(() => {
            loginView.style.display = 'none';
            regView.style.display = 'block';
            setTimeout(() => regView.classList.add('active'), 50);
            title.innerText = 'Регистрация';
        }, 400);
    }
}






<?php
session_start();
require_once 'db.php'; // Используем ваш файл подключения

$email = $_POST['email'];
$password = $_POST['password'];

// Проверка пользователя в БД
$check_user = mysqli_query($connect, "SELECT * FROM `users` WHERE `email` = '$email'");

if (mysqli_num_rows($check_user) > 0) {
    $user = mysqli_fetch_assoc($check_user);

    // Проверяем пароль (предполагается, что при регистрации вы использовали password_hash)
    if (password_verify($password, $user['password'])) {
        $_SESSION['user'] = [
            "id" => $user['id']
        ];
        header('Location: ../profil.php');
        exit();
    } else {
        echo "Неверный пароль";
    }
} else {
    echo "Пользователь не найден";
}
?>