What you do after checking the REQUEST METHOD you trim the POST array all at once, then you check if the particular fields are empty, If they are, you put the errors in an error array. Just past that, you check the errors array and if it is not empty, you loop over each of the errors and output them to the user.
$error = [];
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
// Trim POST array here....
if (empty($_POST['name']))
{
$error['name'] = 'Name Required.';
}
if (empty($_POST['phone']))
{
$error['phone'] = 'Phone Required.';
}
if ($error)
{
// Handle errors
}
else{
//Processs Form
}
}