Я так понимаю надо условие с куки написать, типа если юзер, скрыть кнопку, но как грамотно это записать не понимаю.
Вот код авторизации:
<?php
$login = filter_var(trim($_POST['login']),
FILTER_SANITIZE_STRING);
$pass = filter_var(trim($_POST['pass']),
FILTER_SANITIZE_STRING);
$pass = md5($pass);
$mysql = new mysqli('localhost', 'root', 'root', 'videoteka');
$result = $mysql->query("SELECT * FROM `users` WHERE `login` = '$login' AND `pass` = '$pass'");
$user = $result->fetch_assoc();
if(count($user) == 0){
echo "Такого пользователя не существует";
exit();
}
setcookie('user', $user['name'], time() + 3600 * 2, "/");
$mysql->close();
header('Location: /videoteka');
?>
Вот html разметка с php:
<header class="header">
<div class="container header__container">
<div class="row">
<div class="col-12">
<div class="header__menu">
<h1 class="header__menu_title">Videoteka</h1>
<form action="">
<input type="search" name="" class="header__menu_search" id="search" placeholder="Поиск по сайту">
</form>
<div class="header__menu_auth">
<span class="user-name"><?=$_COOKIE['user']?></span>
<button class="btn btn-outline-dark header__menu_signin">Войти</button>
<button class="btn btn-outline-dark header__menu_register">Регистрация</button>
<button class="btn btn-outline-dark header__menu_logout"><a href="exit.php">Выйти</a></button>
</div>
</div>
</div>
</div>
</div>
</header>
<main class="main">
</main>
<!-- Модальные окна -->
<div id="openModal" class="modal modal-reg">
<?php
if($_COOKIE['user'] == ''):
?>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Регистрация</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="check.php" method="post">
<input type="text" name="login" id="login" class="form-control" placeholder="Введите логин">
<input type="password" name="pass" id="pass" class="form-control" placeholder="Введите пароль">
<input type="text" name="name" id="name" class="form-control" placeholder="Введите имя">
<button class="btn btn-success" type="submit">Зарегистрироваться</button>
</form>
</div>
</div>
</div>
<?php else: ?>
<?php endif;?>
</div>
<div id="openModal" class="modal modal-auth">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Авторизация</h3>
<button type="button" class="close close-auth" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="auth.php" method="post">
<input type="text" name="login" id="login" class="form-control" placeholder="Введите логин">
<input type="password" name="pass" id="pass" class="form-control" placeholder="Введите пароль">
<button class="btn btn-success" type="submit">Войти</button>
</form>
</div>
</div>
</div>
</div>