too long

I have a form displaying via php after no results were displayed in the original query. The form displays fine but when it is submitted it goes to index.php instead of processing using $_SERVER['PHP_SELF'].

echo "<form method='post' action='". $_SERVER['PHP_SELF']."'>";
echo $error['find'];
echo "<p><label for='find'>Search for Your Favorite Location:</label><br />";
echo "<input type='text' id='find' name='find' value='".($_POST['find'] ? htmlentities($_POST['find']) : '')."' /></p>";
echo "<p><input type='submit' name='submitLocation' value='Submit' /></p></form>";

You can achieve that result by leaving action empty. I cleaned up the code a bit, and it now looks like this:

<?php
if (isset($_POST['submitLocation'])) 
{
 echo isset($_POST['find']) ? htmlentities($_POST['find']) : '';
}
?>

<html>
<body>
<form action="" method="post">
<p><label for='find'>Search for Your Favorite Location:</label><br/>
<input type='text' id='find' name='find' value='' /></p>
<input type='submit' name='submitLocation' value='Submit' />
</form>
</body>
</html>

It checks if the form is submitted or not with PHP's isset() function. If it was: then it simply echoes the string the user inputted.