To pass data between files, like login.php, home.php, use <? session_start()?>.

Use if(count($_POST)>0) and isset($_POST) to check if the page is open by URL or submition.

action="<?php echo $_SERVER['PHP_SELF']; ?>" to make a self direct form.

To stop some special characters from being interpreted, use the HTMLSPECIALCHARS() to present the exactly original input.