1

I started a few days ago with FPDF and I decided to make an HTML form so when clicking "Submit" the server creates and returns a PDF file with the form inputs.

Here is my form:

<form action="operation.php">
    <p><label>Departure position (use Plus code)</label>
       <input type="text" name="departu">
    </p>

    <p><label>Destiantion (use Plus code)</label>
        <input type="text" name="arrival">
    </p>

    <p><label>Vehicle used</label>
       <select name="vehicle">
            <option value="0000AAA">0000AAA - CITR-C4</option>
            <option value="9999ZZZ">9999ZZZ - PEU-308</option>
       </select>
    </p>

    <p>
    <input type="submit" value="Get Operation Plan" name="submit">
</form>

And here my PHP document:

<?php
    require ('fpdf/fpdf.php');
    $departu = $_POST['departu'];

    $pdf = new FPDF('P', 'mm', 'A4');

    $pdf->AddPage();
    $pdf->SetFont('Courier', '', 11);
    $pdf->Cell(30, 7, $departu, 0, 1, 'L');

    $pdf->Output();

?>

I run my MAMP server on my MBP and input the data on the form.

No errors are found and the PDF document is generated. Notwithstanding, this PDF file is empty.

What is the correct way of making that departu variable that I entered appear in the PDF file?

Thanks for your help!

1 Answers1

2

Everything looks good in your code, but maybe you could try adding form method to send data like GET or POST.

Try it and tell me if It helps :)

<form action="operation.php" method="post">