How to make so that after entering the text variable test on the page index.php

//Это index.php <form action="index.php" method="POST"> <input type="text" name="test"> <input type="button" name="button"> </form> 

processing php, and the answer, that is, without redirects. That is, how to make action="index.php"

Here is the source:

 <html> <head> <title>Главная страница</title> </head> <body> <?php $test=$_POST[text]; echo "Вы ввели:".$test; ?> <form action="" method="POST"> <input type="text" value="Введите текст здесь..." name="text"> <input type="button" name="button"> </form> </body> </html> 


 Вы ввели: //Тут форма(текст и кнопка) 

And I need to first was just a form, and then just the inscription "Вы ввели <переменная из формы>"

    1 answer 1

    he answered his own question) leave the action blank so that the file will process itself))

    After the form write this code:

     <?php if(isset($_POST['button'])) { $text = $_POST['text']; if($text == '') echo 'Заполни поле'; else echo $text; }