: If you want to do it without refreshing the page, using popups - you probably want to do it in javascript, instead of php as php is a server-side language.
:
Nope, if you do it it javascript, your script is not secured. data may be messed if somebody means it.
To do it in PHP, you should echo PHP variables rite on input feilds. While the form is not submited, they are null.
once the form is submited, if there is one which is not valid, set it to empty or null. Then the output would still be empty. Now you can output the error ms to your users.
Good luck