This is a copy of what I am using to accomplish the task. Of course, you will need to edit the if and the else conditions to suit your data requirements.
This code, in the if condition case, prints the message you see below for the if condition and likewise for the elseif condition.
The code below including the table must be placed in your file you named mailing php.
I have only my standard page header and then these lines of code and then the email send code and then my standard page footer.
The appropriate output appears in the small table in the top center of the page. And the form is not on the page.
For example, the user has entered unqualified data into the form and clicks Send or Submit (whatever value you gave to your form's action button) then the user follows the instruction "Please use your back button and complete all of the required form fields, then resubmit." The form reappears on the screen with all of the data that was previously entered - if any.
I hope this or some part of it is what you are lacking in your code.
If You need more instruction or comments, I will again attempt to help.
<table align="center" cellpadding="5" border="3" width="60%" bgcolor="#ffffff">
<tr><td align="center" valign="middle">
<b><font face="Helvetica, Arial, sans-serif" color="#6600ff" size="2">
<?php if ($action == ("Send the emails") && ($vstor == "") || ($vstormal == "") || ($recp1 == "") || ($recpmal1 == "")) echo "Please use your back button and complete all of the required form fields, then resubmit." ;
elseif ($action == ("Send the emails") && ($vstor != "") || ($vstormal != "") || ($recp1 != "") || ($recpmal1 != "")) echo "Thank you, $vstor for recommending the URL. You have a dynamite day!" ; ?>
</font></b></td></tr></table>
BTW The html code above is: html 4.01 Transtional
And BTW I validate all of my html, htm and php pages, If you want more info on validation I,ll seend you the URL via email.
Good Luck with your project,