【发布时间】:2017-02-10 06:11:58
【问题描述】:
我正在使用 PHP 和外部库 FPDF 和透明度脚本生成 PDF:alphapdf。
代码:
HTML
<form name="myform" method="POST" target="_blank">
<button type="submit" formaction="print.php"> Print </button>
<input type ="text" name="name"></input>
</form>
PHP
<?php
require('alpha/alphapdf.php');
// Instanciation of inherited class
$pdf = new AlphaPDF();
$pdf->AddPage();
$pdf->SetLineWidth(1.5);
// draw jpeg image
$pdf->Image('my-image.jpg',0,0,220,300,'JPG');
// print name
$pdf->SetFont('Arial', '', 12);
$name = $_POST['$name'];
$pdf->Text(10,28,$name);
$pdf -> Output();
?>
【问题讨论】:
-
那么你在 pdf 中得到了什么? echo $_POST['name'] ,看看你到底收到了什么。
-
我也做了 echo 和 print_r,数据确实已发布,但问题在于分配给变量,通过下面的答案解决了谢谢:)