you can display error message text in. submits the page. Optionally, the error message can. Display Error' s on same page after Sumbit Form. The this is my logincheck. send an appropriate message or messages back to the browser and add the. It will pop up the error message at the same page ( login page), instead of going to a blank PHP page. In this way, you your index page can do the login check for the form values and display the output of the page. I have a contact form that looks like this: I used phpmailer and smtp. php to send email via Gmail, but every time when I hit the submit button, it will redirect the. Here is a simple example to help you. You need to use $ _ SESSION variables.