生成qrcode后PHP脚本停止运行

Hello so basically I have this working code that generates a qr code image.

<?php
if (isset($_POST['btn_submit'])) {
    include('phpqrcode/qrlib.php');
    require '../db/dbc.php';
    try {
        $characters           = 'abcdefghijklmnopqrstuvwxyz0123456789';
        $strlength            = 5;
        $string               = '';
        for ($i = 0; $i < $strlength; $i++) {
            $string .= $characters[rand(0, strlen($characters) - 1)];
        }

        $query       = "INSERT INTO tbl_residents (fname, mname, lname, address, uname, pword, acct_status, department, contact_no, date_reg) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
        $stmt        = $dbc->prepare($query);
        $pword       = sha1($string);
        $now         = date('m/d/Y');
        $acct_status = "active";
        $stmt->bindParam(1, $_POST['txt_fn']);
        $stmt->bindParam(2, $_POST['txt_mn']);
        $stmt->bindParam(3, $_POST['txt_ln']);
        $stmt->bindParam(4, $_POST['txt_address']);
        $stmt->bindParam(5, $_POST['txt_un']);
        $stmt->bindParam(6, $pword);
        $stmt->bindParam(7, $acct_status);
        $stmt->bindParam(8, $_POST['txt_dept']);
        $stmt->bindParam(9, $_POST['txt_cnum']);
        $stmt->bindParam(10, $now);
        $stmt->execute();
    }
    catch (PDOException $e) {
        echo "Error: " . $e->getMessage();
    }
}

$uncode = intval($string, 36);
// outputs image directly into browser, as PNG stream 
QRcode::png("login-link.php?code=$uncode");


?>

If I wanted to add details such as name, department and contact number under the php closing tag, it won't show up. But the code still runs and still generates a qr code image.

Below the php end tag I added this but it doesn't work.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ID Creation</title>
</head>
<body>
   Name: <?= $_POST['txt_fn']. " " . $_POST['txt_mn'] . " " . $_POST['txt_fn']; ?>  <br />
   Department: <?= $_POST['txt_dept']; ?>  <br />
   Contact No.: <?= $_POST['txt_cnum']; ?>
</body>
</html>

If you remove the qr code generation line below, it works.

$uncode = intval($string, 36);
// outputs image directly into browser, as PNG stream 
QRcode::png("login-link.php?code=$uncode");

So basically, the line QRcode::png("login-link.php?code=$uncode"); stops the code from executing. It doesn't read any lines below it. Any thoughts? Thank you

Hello so I've managed to fix my own problem by adding parameter to the qrcode generator and it looks like this

From

QRcode::png("login-link.php?code=$uncode");

To

QRcode::png("login-link.php?code=$uncode", "qr_images/$string.png");

And in my html code it looks like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ID Creation</title>
</head>
<body>
   <img src="qr_images/<?= $string.".png"; ?>">
   Name: <?= $_POST['txt_fn']. " " . $_POST['txt_mn'] . " " . $_POST['txt_fn']; ?>  <br />
   Department: <?= $_POST['txt_dept']; ?>  <br />
   Contact No.: <?= $_POST['txt_cnum']; ?>
</body>
</html>

Thanks for your time looking at my problem.