使用JS在alert()之前显示pdf

时间:2017-05-29 00:26:30

标签: javascript php pdf fpdf

我想在点击提交按钮时显示我的PDF文件,但是alert()首先出现,pdf永远不会加载。

我也在html中使用onsubmit,所以当提交时,首先点击onsubmit,然后是alert()消息。

我希望这些步骤发生:

onsubmit - >已加载pdf文件 - >警报()

<?php

$con = mysqli_connect('localhost', 'root', "", 'catering_info');

        $main = $_GET['main'];
        $last= $_GET['last'];
        $first = $_GET['first'];
        $middle = $_GET['middle'];

if (isset($_GET['submit'])) {
    if (!empty($last) && !empty($first) && !empty($middle) && !empty($street) && !empty($brgy) && !empty($town) && !empty($prov) && !empty($mobile) && !empty($email) && !empty($event) && !empty($venue) && !empty($number)) {

    //--- sending to database
        $sql = "INSERT INTO client_info (ref_no, last_name, first_name, middle_name) VALUES('$main','$last','$first','$middle')";

        if (!mysqli_query($con, $sql)) {
        echo"REQUEST DENIED";
        }
        else
        {
        echo"<script type='text/javascript'> alert('Successfully Sent to Admin, you will now be proceeded back to Home Page!'); window.location.href='long_page.html';  </script>";
        }


            require("fpdf/fpdf.php");
            $pdf= new FPDF();
            $pdf->Addpage();
            $pdf->SetFont('Times',"", 10);
            $pdf->Cell(0,10,"Reservation Form",1,1, 'C');
            $pdf->Cell(40,5, "Reference ID:", 0,0);
            $pdf->Cell(40,5, "$main ,", 0,1);
            $pdf->Cell(40,5, "Name:", 0,0);
            $pdf->Cell(40,5, "$last  ,", 0,0);
            $pdf->Cell(40,5, "$first ", 0,0);
            $pdf->Cell(40,5, "$middle", 0,1);
            $pdf->output("PDF_RESERVATIONS/" . $last . "-" . $first .".pdf", 'F');

    }   
}

&GT;

如果你们知道更好的方法,请帮忙。无论如何,我只是尝试使用PHP x JS尽可能多的PHP或JS ...谢谢。

0 个答案:

没有答案