<form class="answer-input-div" method="post" action="<?=$_SERVER['PHP_SELF']?>" <?php if($i==5) echo "style='display:none;'"; ?>>
<input type="text" required name="answer" placeholder="Введите ответ в это поле" class="answer-input">
<button class="answer-button" type="submit">Проверить</button>
</form>
<?php
$answerinf = False;
$answertrue = 33;
$usersanswer = $_POST['answer'];
$istinnost = "Нет";
$i = 0;
if ($usersanswer == $answertrue) {
$answerinf = True;
} else {
$i++;
}
if ($answerinf == True) {
$istinnost = "Да";
}
?>
<h2>Попыток: <?php echo "$i"?>/5.</h2>
<h2>Решение: <?php echo "$istinnost"?>.</h2>
<?php
session_start();
if(!isset($_SESSION['count'])) {
$_SESSION['count']=0;
}
if($_SESSION['count']>5) {
$_SESSION['count'] = 0;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>TEST</title>
<meta charset="utf-8" />
</head>
<body>
<form class="answer-input-div" method="post" action="<?=$_SERVER['PHP_SELF']?>" <?php if($_SESSION['count']==5) echo "style='display:none;'"; ?>>
<input type="text" required name="answer" placeholder="Введите ответ в это поле" class="answer-input">
<button class="answer-button" type="submit">Проверить</button>
</form>
<?php
$answerinf = false;
$answertrue = 33;
$usersanswer = $_POST['answer'];
$istinnost = "Нет";
$i = 0;
if ($usersanswer == $answertrue) {
$answerinf = true;
} else {
$_SESSION['count']++;
}
if ($answerinf == True) {
$istinnost = "Да";
}
?>
<h2>Попыток: <?php echo "{$_SESSION['count']}"?>/5.</h2>
<h2>Решение: <?php echo "$istinnost"?>.</h2>
</body>
</html>