Sending something to the browser with echo"Your Login Name or Password is invalid"; does not make any sense before calling header("location: invalid.html"); because you can’t send header information after you send payload.
You should remove the echo-Line or the redirect will not work.
In addition to that, session_register() is deprecated by PHP 5.3 and got removed in 5.4. Just use session_start().
solved Always redirect me to admin.php [closed]