<?php
use JetBrains\PhpStorm\NoReturn;
session_start();
#[NoReturn] function redirectBack($data = null) {
if (isset($data)) {
$_SESSION['answer'] = $data;
} else {
unset($_SESSION['answer']);
}
header('Location: '. $_SERVER['REQUEST_URI']); exit;
}
$login = 'Lane';
$password = 'admin';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($_POST['login']) || empty($_POST['password'])) {
redirectBack("Something is incorrect...");
}
if ($_POST['login'] != $login || $_POST['password'] != $password) {
redirectBack("Something is incorrect...");
}
redirectBack("The authorization went well!");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="styles.css" rel="stylesheet" />
<title>Project - ведение списков</title>
</head>
<body>
<div class="header">
<div class="logo"><img src="i/logo.png" width="68" height="23" alt="Project" /></div>
<div style="clear: both"></div>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="left-collum-index">
<h1>Возможности проекта —</h1>
<p>Вести свои личные списки, например покупки в магазине, цели, задачи и многое другое. Делится списками с друзьями и просматривать списки друзей.</p>
</td>
<td class="right-collum-index">
<div class="project-folders-menu">
<ul class="project-folders-v">
<li class="project-folders-v-active"><span>Авторизация</span></li>
<li><a href="#">Регистрация</a></li>
<li><a href="#">Забыли пароль?</a></li>
</ul>
<div style="clear: both;"></div>
</div>
<div class="index-auth">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form action="" method="post">
<tr>
<td class="iat">Ваш логин: <br/> <label>
<input type="text" size="30" name="login" />
</label>
</td>
</tr>
<tr>
<td class="iat">Ваш пароль: <br/> <label>
<input type="password" size="30" name="password" />
</label>
</td>
</tr>
<tr>
<td><input type="button" value="Войти" name="btn" /></td>
</tr>
</form>
</table>
</div>
</td>
</tr>
</table>
<?php if (!empty($_SESSION['answer'])) : ?>
<div class="alert alert-warning" role="alert">
<?= $_SESSION['answer']; ?>
</div>
<?php endif; ?>
<div class="footer">© <nobr>2018</nobr> Project.</div>
</body>
</html>