Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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 将数据从HTML表单提交到pdf_Php_Html_Oop - Fatal编程技术网

Php 将数据从HTML表单提交到pdf

Php 将数据从HTML表单提交到pdf,php,html,oop,Php,Html,Oop,我想将HTML表单中的数据写入PDF文档。这是我的密码: home.php <!doctype HTML> <html> <body> <form action="test.php" method="post"> NAME:<input type="text" name="name" ><br><br> E-mail:<input type="text" name="em

我想将HTML表单中的数据写入PDF文档。这是我的密码:

home.php

<!doctype HTML>
<html>
  <body>
    <form action="test.php" method="post">
      NAME:<input type="text" name="name" ><br><br>
      E-mail:<input type="text" name="email"><br><br>
      Submit:<input type="submit" name="submit" value="submit">
    </form>
  </body>
</html>
<?php
  if(isset($_POST['submit'])){
    if(empty($_POST['name'])){
      echo "fill"."<br><br>";
    }

    if(empty($_POST['email'])){
      if(empty($_POST['name'])){
        echo "check";
      }
    }   
  }
?>
test.php

<?php
  require('fpdf.php');

  class PDF extends FPDF {
    function Header() {
      $this->SetFont('Helvetica','B',15);
      $this->SetXY(50, 10);
      $this->Cell(0,10,'This is a header',1,0,'C');
    }

    function content() {
      $html = '<table> 
          <tr>
          <td>'.$_POST['name'].'</td>
          </tr>
          <tr>
          <td>'.$_POST['email'].'</td>
          </tr>
          </table> ';
          $this->write($html);
        }

        function Footer() {
          $this->SetXY(100,-15);
          $this->SetFont('Helvetica','I',10);
          $this->Write (5, 'This is a footer');
        }
      }
      $pdf=new PDF();
      $pdf->AddPage();
      $pdf->Output();
    ?>

有问题吗?问题是我无法将数据保存到pdfSo中,当您尝试完成此操作时,它会给您带来什么错误?它只显示页眉和页脚部分而不是内容部分有许多fpdf库。请提供您正在使用的链接。我认为函数内容不合适。
       by changing libraries name i got  the  answer.
hope yhis will help  you  to.



<?php
require('htmlFPDF/html2fpdf.php');
    $pdf=new HTML2FPDF();
    $pdf->AddPage();
    $fp = fopen("sample.html","r");

        $strContent = "<table style='width:100%; border=1px solid black;padding:5px;'>
        <thead>
        <tr>
        <td><h1 style='text-align:center'><b>Your submitted data is</b></h1></td>
         </tr>
         <tr>
          <td>Name</td>
          <td>$_POST[name]</td></tr>
         <tr>
          <td>Email</td>
          <td>$_POST[email]</td></tr>
         <tr>
          <td>Telephone</td>
          <td>$_POST[telephone]</td></tr>
         <tr>
          <td>ADDRESS</td>
          <td>$_POST[address]</td></tr>
         <tr>
          <td>Deliver or Pickup</td>
          <td>$_POST[delivery]</td></tr>
         <tr>
          <td>Camper Tank</td>
          <td>$_POST[tank_size]</td></tr>
        [16-Sep-14 5:31:48 PM] VIKRANT SHARMA: </thead>
        </table>";

    $pdf->WriteHTML($strContent);
    $pdf->Output('Plastic-data.pdf','D');
        echo "PDF file is generated successfully!";
?>