I have a form, which i have programmed with AngularJs. When the user submits that form a php script (made with Slim) gets executed, which inserts the formdata into the DB and generates an E-Mail (PHPmailer).
Now to the question:
I get the structure from the email with file_get_contents from a template and replace the placeholders with str_replace.
template:
<h2>User Information</h2>
<table>
<tbody>
<tr><th>Firstname:</th><td>%firstname%</td></tr>
<tr><th>Lastname:</th><td>%lastname%</td></tr>
</tbody>
</table>
<br>
<h2>Other Information</h2>
<table>
<tbody>
<tr><th>Phone:</th><td>%phone%</td></tr>
<tr><th>E-Mail:</th><td>%email%</td></tr>
<tr><th>Organisation:</th><td>%organisation%</td></tr>
</tbody>
</table>
My problem is that not all of these fields are required and i want to delete the whole table + the heading if none of these variables (phone, email, organisation) is set.