这是functions.php文件:
<?php
include 'QR_BarCode.php';
function url(){
$qr = new QR_BarCode();
$qr->url('here i want data sent from form');
$qr->qrCode();
}
?>这是我的html表单index.php。我想在index.php页面上生成二维码。
<form method="post" id="form_id" action="functions.php">
<input type="tel" name="number">
<input type="submit" id="sub" name="sub">
</form>Here is the link I generate qr codes from.
请帮帮我!提前谢谢。
发布于 2017-04-12 21:31:24
首先,你需要运行你的函数。现在它被声明了,但是你什么也不做。
下面是一个如何做到这一点的例子:
<?php
include 'QR_BarCode.php';
function url($number, $sub){
if(empty($number) || empty($sub)) {
die('Error. Fields cannot be empty');
}
$qr = new QR_BarCode();
$qr->url();
$qr->qrCode();
}
// This is only example. You should validate those inputs.
url($_POST['number'], $_POST['sub']);但是请记住,在没有$_POST数据的情况下运行functions.php将导致PHP通知。您可以检查请求中的$_POST值,然后才能运行此函数
if(isset($_POST['number']) && isset($_POST['sub'])) {
url($_POST['number'], $_POST['sub']);
}https://stackoverflow.com/questions/43316611
复制相似问题