How can I pass the if
statement in the $html
? I'm building pdf from the values of a form and I'm not sure how I can pass this if
statement with the html.
I'm using mPDF
version 6 to generate pdf.
I've researched for a while but didn't couldn't figure out the right way. So, I really appreciate your suggestions. Thanks in advance.
<?php
include('mPDF/mpdf.php');
$name = $_POST["name"];
$age = $_POST["age"];
$html = '<html>
{if (!empty($_POST['name'])) echo 'Name: ' . $name;}<br>
{if (!empty($_POST['age'])) echo 'Age: ' . $age;}
</html>';
$mpdf = new mPDF();
$mpdf->WriteHTML($html);
$mpdf->Output();
?>
This is the form in case you need a look:
<form method="post" action="generatePDF.php">
Name: <input type="text" name="name" id="name" /><br>
Age: <input type="text" name="age" id="age" /><br>
</form>