$loader->registerNamespaces([
'App' => APP_PATH,
]);
<?php
$showForm = false;
// Была отправлена форма
if(count($_POST))
{
// Все поля заполнены
if (!empty($_POST['name']) && !empty($_POST['age']) && !empty($_POST['message']))
{
$name = strip_tags($_POST['name']);
$age = strip_tags($_POST['age']);
$text = strip_tags($_POST['message']);
echo 'Привет, '.$name.'<br>';
echo 'Вам '.$age.' лет <br>';
echo 'Ваше сообщение: '.$text;
}
// Что-то не заполнено
else {
echo "Some fields are still empty. Try entering again";
$showForm = true;
}
} else {
$showForm = true;
}
?>
<? if($showForm): ?>
<form action="" method="POST">
<input type="text" name="name" placeholder="Введите имя..."> <br> <br>
<input type="text" name="age" placeholder="Введите возраст..."> <br> <br>
<textarea name="message" placeholder="Введите текст..."></textarea> <br> <br>
<input type="submit" name="submit">
</form>
<? endif; ?>
http://phptest/index.php?r=post
или http://phptest/post
(если включены prettyUrl в urlManager)