Instead of hard coding the name of a script use a superglobal reference.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

 

<?php
 if (isset($_POST['submit'])) {

$text = $_POST['text'];
$output_form = false;

if ( empty($text) {
  echo 'Text is empty'<br />;
}
else {
  $output_form  = true;
}

if ($output_form) {
?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']' ?>"> 
  <label for="text">Text:</label><br />
  <input id="text" name="text" type="text" size="10" /> <br />
  <input type="submit" name="submit" value="Submit" />
</form>

<?php
 }
?>