Redirecting output back to html page

I have a html page with a form with all the processing done on a separate php file, though what should I do if I want to report an error in form validation back to the existing html page alongside the users form instead of just doing die() and creating a new page to report the form validation error to the user.

I believe that this is not possible if the page does not have a .php extension.

If it does have a .php extention you could do something like below, obviously = error is not valid code but you would replace the $form_part with the part that you are validating and error with what it should equal or match.

if($form_part1 = error) {
    $error_msg = "Error Message";
} elseif($form_part2 = error) {
    $error_msg = "Error Message 2";
} else {
    // Validate the form

and then on your page that contains the form something like this should work

if(isset($error_msg)) {
    echo $error_msg;