You should not refresh the whole page on a form submit, its a better way to send the login details in an AJAX request, or submit the form into a hidden iframe. On a success login you can redirect the parent page from this iframe.
You should read this pop-up documentations how to load on a body load, in this case you can store the entered details in $_SESSION, and remain the form input/values.