【问题标题】:How to write _POST variable data on a PDF generated using FPDF?如何在使用 FPDF 生成的 PDF 上写入 _POST 变量数据?
【发布时间】: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,数据确实已发布,但问题在于分配给变量,通过下面的答案解决了谢谢:)

标签: php pdf fpdf


【解决方案1】:

这个

$name = $_POST['$name'];

应该是

$name = $_POST['name'];

试试var_dump($_POST)print_r($_POST) 来证明。 也尝试打印$_POST['$name']

【讨论】:

    猜你喜欢
    • 2013-05-12
    • 1970-01-01
    • 2021-11-03
    • 2018-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多