0
Fala galera,
I have a file called post_forms.php
that picks up the results of $_POST[]
, must fill variables inside the file form_xxx.html
, create a PDF with Dompdf lib and send with Phpmailer.
See a part of each file:
post_forms.php
setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese");
date_default_timezone_set('America/Bahia');
$data_cadastro = utf8_encode(ucfirst(strftime('%A, %d/%m/%Y, %H:%M:%S')));
$tipo_form = $_POST['tipo-form'];
$protocolo = 'DA'.date("Ymdis");
switch ($tipo_form)
{
case"Form A":
ob_start();
include("forms/form_A.html");;
$html = ob_get_clean();
break;
}
echo $html;
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
form_A.html
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
</head>
<body>
<main>
<table class="table table-bordered" style="text-align:center;">
<tr>
<th rowspan="2" align="center"><img src="img/logo.png"></th>
<th colspan="4" style="font-size: 1.5em;">FORMULÁRIO - Formulário Tipo A</th>
</tr>
<tr>
<th colspan="2"><strong>$tipo_form</strong> - <big>$protocolo</big></th>
<th colspan="2"> $data_cadastro</th>
</tr>
<tr>
...
</tr>
<tr>
...
</tr>
<tr>
...
</tr>
<tr>
...
</tr>
</table>
</main>
<script> ... </script>
</body>
</html>
I have no problem with the Dompdf classes and even with Phpmailer, I can generate the pdf and send by email.
What I need to know is, why the PHP variables that are inside the html file are being written with the String containing the name of the Ex variable: $data_cadastro
and is not being printed the content of the variable that would be by Ex: Saturday, 08/09/2018,
11:34:00
Friend tries the following.... change line <th colspan="2"><Strong>$type_form</Strong> - <big>$protocol</big></th> <th colspan="2"><? echo $data_registration? > </th> for <th colspan="2"><Strong>$type_form</Strong> - <big><?= $protocol? ></big></th> <th colspan="2"><? echo $data_cadastre? ></th>
– Israel Zebulon
See the answer: https://answall.com/questions/7703/utilizo-php-dentro-de-um-html-ou-um-html-dentro-de-um-php
– Israel Zebulon