PHP PDF Issuance System

We are going to develop a simple application to download a PDF document (It could be admission letter, Issuing a certificate to many people). You could use this code to develop such an application. I am going PHP together with FPDF and select data from the database when a user inserts his/her unique number.

You need to download FPDF from this link

<?php  include "includes/connecttodatabase.php"; ?>

<?php


use \setasign\Fpdi\Fpdi;

if (isset($_POST['submit'])) {

   $UNIQUEno = "";

    $UNIQUEno =strip_tags($_POST['UNIQUEno']);

    $UNIQUEno = $conn->real_escape_string($UNIQUEindexno);

 $sql = "SELECT * FROM database WHERE SUserUniqueNumber = '{$UNIQUEno}' ";  
 
    $result = $conn->query($sql);

    
    while ($row = $result->fetch_assoc()) {


        $user_id = $row['UserID'];   //This is in the databse
        $$user_number_UNIQUE_no = $row['UserUniqueNumber'];
        $$user_Name = $row['UserName'];

        
    }


    if ($UNIQUEno = $UserUniqueNumber) {
        
  include "pdflib/fpdf.php";
//include "FPDI/src/fpdi.php";
//include "FPDI/src/FpdfTpl.php";
//include "FPDI/src/autoload.php";
//Three Lines start at the Case

require_once('FPDI/src/autoload.php');

$pdf = new FPDI('P', 'mm', 'Letter');

$pagecount = $pdf->setSourceFile('templates/certsample.pdf');
$tplidx = $pdf->importPage(1, '/MediaBox');

$pdf->addPage();
$pdf->useTemplate($tplidx, 0, 0, 217);

$pdf->SetFont('Times', 'B', 10);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetXY(27, 76);

$pdf->Write(0, $user_Name);


$pdf->Output('Certwithname.pdf', 'D');
     


?>

 

Translate »