PHP Snippet 1:
// Your required fields:
$fields = ['parent', 'child', 'contacts', 'email', 'bbd', 'city', 'mess'];
// Your data is collected here:
$data = [];
// Any errors are collected here:
$errors = [];
PHP Snippet 2:
// Loop to check your required fields:
foreach($fields as $field) {
// If value exists, add to $data:
if(!empty($_POST[$field])) {
$data[$field] = $_POST[$field];
}
// Else add error:
else {
$errors[] = 'Missing field: ' . $field;
}
}
if(empty($errors)) {
// No errors, send your email
// You can use "Vanema nimi {$data['parent']}...",
// ... otherwise: extract($data) to use $parent etc.
}
else {
// You could report those errors, or redirect back to the form, or whatever.
}