0
I have a form that when sent, executes an action that directs to another PHP page, where several scripts are executed and at the end is generated a PDF file to download.
All scripts and PDF generation are executed correctly, but instead of directing to the page referenced in action, which in addition to executing scripts, also has the function of showing a message of success or error, the system continues on the form screen, passing the impression to the user that the form was not sent, possibly leading to duplicated records.
Form start and end:
<form id="form" method="post" action="function.php" enctype="multipart/form-data">
<input type="submit" name="submit" class="button" value="Enviar">
PHP code for PDF generation:
header('Pragma: no-cache');
ini_set('max_execution_time', 300);
$mpdf=new mPDF();
$mpdf->SetDisplayMode('fullpage');
$html = mb_convert_encoding($html, 'UTF-8', 'UTF-8');
$stylesheet = file_get_contents('_css/pdf_style.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($html,2);
$mpdf->Output('myPDF.pdf', 'D');
$mpdf->charset_in='windows-1252';
Demonstration of what happens after sending the form:
I’ve checked the MPDF documentation, but I couldn’t find a function to solve this problem. Would this be a normal MPDF behavior or is missing some MPDF or PHP configuration?