I think you're confusing client-side and server-side operations. If you simply want to change the appearance of your form page upon submission, you can indeed handle that entirely on the client side.
If you want to stay on that form page, but change its appearance based on information returned from your server (as in your sample php code), then you'll need to do an asynchronous form submission. You can use jQuery's $.ajax()
function or its relatives, then change your page in the callback function based on the success/failure information you return from your server-side script.
Simple example:
$.post(
'your_php_handler.php',
$("#your_form").serialize(), // send all your form fields
function(data) { // data = what comes back from your php handler script
$('#thing_you_want_to_change').html(data);
}
);