无法重新加载文件,并且fpdf输出不起作用

时间:2019-03-30 06:03:18

标签: php mysql action fpdf

我正在尝试在表单执行所有验证并提交表单后创建一个pdf文件。如果我将form.php付诸实践,将不会执行所有验证。但是,如果使用window.location发出脚本警报,它将执行,但输出pdf无法重新加载。

这是我的意思:

echo '<script type="text/javascript">'; 
                echo 'alert("registered");'; 
                echo 'window.location.href = "form.php";';
                echo '</script>';

form.php

 <?php
include('includes/connections.php');
        $date = date('l | F d, Y h:i A');
        $lname = $_POST['lname'];
        $fname = $_POST['fname'];
        $midname = $_POST['midname'];
        $address = $_POST['address'];
        $nfather = $_POST['nfather'];
        $nmother = $_POST['nmother'];
        $guardian = $_POST['guardian'];
        $contactnum = $_POST['contactnum'];
        $relationship = $_POST['relationship'];
        $bday = $_POST['bday'];
        $gender = $_POST['gender'];
        $status = $_POST['status'];

ob_start();
require('fpdf/fpdf.php');

        $pdf = new FPDF();
        $pdf->AddPage();
        $pdf->SetFont('Times','B',14);

        $pdf->Ln();
        $pdf->Image('images/logo.png',93,10,30,30);

        $pdf->SetFont('Courier','B',14);
        $pdf ->SetLeftMargin(20);
        $pdf->Ln(14);
        $pdf->Cell(0, 1, "PERSONAL INFORMATION:", 0, 0, 'L');

        $pdf->SetFont('Times','',12);
        $pdf->SetLeftMargin(40);
        $pdf->Ln(8);
        $pdf->Cell(0, 1, "LAST NAME: $lname", 0, 0, 'L');
        $pdf->Ln(8);
        $pdf->Cell(0,1,"FIRST NAME: $fname",0,0,'L');
        $pdf->Ln(8);
        $pdf->Cell(0,1,"MIDDLE INITIAL: $midname",0,0,'L');


        $pdf->SetFont('Times','',12);
        $pdf->SetLeftMargin(40);
        $pdf->Ln(8);
        $pdf->Cell(0, 1, "ADDRESS: $address", 0, 0, 'L');

        $pdf->Ln(8);
        $pdf->Cell(0,1,"NAME OF FATHER: $nfather",0,0,'L');

        $pdf->Ln(8);
        $pdf->Cell(0,1,"NAME OF MOTHER: $nmother",0,0,'L');

        $pdf->Ln(8);
        $pdf->Cell(0, 1, "BIRTHDAY: $bday", 0, 0, 'L');

        $pdf->Ln(8);
        $pdf->Cell(0, 1, "GENDER: $gender", 0, 0, 'L');

        $pdf->Ln(8);
        $pdf->Cell(0, 1, "STATUS: $status", 0, 0, 'L');

        $pdf->SetFont('Courier','B',14);
        $pdf ->SetLeftMargin(20);
        $pdf->Ln(14);
        $pdf->Cell(0, 1, "IN CASE OF EMERGENCY:", 0, 0, 'L');

        $pdf->SetFont('Times','',12);
        $pdf ->SetLeftMargin(40);
        $pdf->Ln(8);
        $pdf->Cell(0, 1, "NAME OF GUARDIAN: $guardian", 0, 0, 'L');

        $pdf->Ln(8);
        $pdf->Cell(0, 1, "CONTACT NUMBER: $contactnum", 0, 0, 'L');

        $pdf->Ln(8);
        $pdf->Cell(0, 1, "RELATIONSHIP: $relationship", 0, 0, 'L');


        $pdf->SetFont('Courier','B',14);
        $pdf ->SetLeftMargin(20);
        $pdf->Ln(14);
        $pdf->Cell(0, 1, "OTHER REQUIREMENTS:", 0, 0, 'L');

        $pdf->SetFont('Times','',12);
        $pdf ->SetLeftMargin(40);
        $pdf->Ln(8);
        $pdf->Cell(0, 1, "____ Good Moral", 0, 0, 'L');

        $pdf->Ln(8);
        $pdf->Cell(0, 1, "____ Form 137 / Card", 0, 0, 'L');

        $pdf->Ln(8);
        $pdf->Cell(0, 1, "____ Birth Certificate / PSA", 0, 0, 'L');

        $pdf->Ln(8);
        $pdf->Cell(0, 1, "____ Dengvaxia Record", 0, 0, 'L');


        $pdf->SetRightMargin(20);
        $pdf->Ln(14);
        $pdf->Cell(0, 1, "_______________________", 0, 0, 'R');
        $pdf->SetRightMargin(28);
        $pdf->Ln(6);
        $pdf->Cell(0, 1, "Signature of Student", 0, 0, 'R');


        $pdf->SetFont('Courier','B',12);
        $pdf ->SetLeftMargin(20);
        $pdf->Ln(14);
        $pdf->Cell(0, 1, "DATE AND TIME REGISTERED:", 0, 0, 'L');
        $pdf->Ln(8);
        $pdf->Cell(0, 1, "$date", 0, 0, 'L');

        $pdf->Output("D", "form.pdf");
?>

所以在这里。它存储到我的数据库,但输出pdf无法重新加载。.

0 个答案:

没有答案