Put this all in one file, named whatever you want:
HTML:
<html>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<label>Name:</label><input type="text" name="name" />
</form>
</body>
</html>
PHP:
<?php
if (isset($_POST['name'])) {
echo 'hi xyz';
} else {
echo 'hello stranger';
}
?>