Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP脚本在qrcode生成后停止运行_Php_Qr Code - Fatal编程技术网

PHP脚本在qrcode生成后停止运行

PHP脚本在qrcode生成后停止运行,php,qr-code,Php,Qr Code,您好,所以基本上我有这个工作代码,生成二维码图像 <?php if (isset($_POST['btn_submit'])) { include('phpqrcode/qrlib.php'); require '../db/dbc.php'; try { $characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; $strlength = 5;

您好,所以基本上我有这个工作代码,生成二维码图像

<?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");


?>

所以基本上,行QRcode::png(“login link.php?code=$uncode”);停止代码的执行。它没有读到下面的任何一行。有什么想法吗?谢谢

您好,我已经设法通过向qrcode生成器添加参数来解决我自己的问题,看起来是这样的

在我的html代码中,它如下所示:

<!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>

ID创建
">
名称:
部门:
联络电话:

感谢您花时间研究我的问题。

您不能从一个应该返回图像的URL返回HTML。该URL将用作图像的
src
属性,它不知道在它之后如何处理HTML。因此,有解决方案吗?我想创建一个IDY您需要两个脚本,一个用于HTML,另一个用于e图像。第一个脚本将把URL放到第二个脚本的
标记中。你能帮我启动代码吗?如果我也在做我的代码,请稍等,谢谢you@Barmar你好,我已经修好了,谢谢
$uncode = intval($string, 36);
// outputs image directly into browser, as PNG stream 
QRcode::png("login-link.php?code=$uncode");
QRcode::png("login-link.php?code=$uncode");
QRcode::png("login-link.php?code=$uncode", "qr_images/$string.png");
<!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>