I have made a simple form which takes values but now I want to make a pdf of submitted form data when I will click on submit means after submitting the form when used will click on submit then all the form values will be in pdf form. (I want to send that pdf via mail but first I want to understand how to make pdf then I will do that later.)
I have written code for the form and then I use help of fpdf and try to understand the use of its classes.
<?php
require('fpdf.php');
/*$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->SetTextColor(50,60,100);
$pdf->AddPage('P');
$pdf->SetDisplayMode(real,'default');
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
*/
$labelname = "Membership Form" ;
include_once 'header.php';?>
I just put those classes in comment or else my membership-form.php will not shown and the blank pdf page will show.
As far I understood that I have to use these functions like addpage, cell and setfont to set the style of pdf, and for putting data I should use this:
function ChapterBody($file)
{
// Read text file
$txt = file_get_contents($file);
// Font
$this->SetFont('Times','',12);
// Output text in a 6 cm width column
$this->MultiCell(60,5,$txt);
$this->Ln();
// Mention
$this->SetFont('','I');
$this->Cell(0,5,'(end of excerpt)');
// Go back to first column
$this->SetCol(0);
}
and this is the part where my mind didn't work as I didn't know about this code. Please tell me how to get data from a form and put in pdf so it will be in pdf after submit.
Here a little part of my form
<table border="0" width="100%;">
<form action="mail_handler.php" method="post">
<tr>
<td>Title</td>
<td>First Name</td>
<td>Middle</td>
<td>Surname</td>
</tr>
<tr>
<td><input type="text" name="title" /> </td>
<td><input type="text" name="fname" /></td>
<td><input type="text" name="middle" /></td>
<td><input type="text" name="surname" /></td>
</tr>
<tr>
<td>Mailing Address</td>
</tr>
<tr>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td colspan="2">Name of Company / Institution & Address</td>
</tr>
<tr>
<td><input type="text" name="noc" width="30%"/></td>
<td><input type="text" name="noc1" width="30%"/></td>
</tr>
<tr>
<td>Office Tel.</td>
<td>Home Tel.</td>
<td>Mobile No.</td>
<td>E-mail</td>
</tr>
<tr>
<td><input type="text" name="office_no" /> </td>
<td><input type="text" name="Home_no" /></td>
<td><input type="text" name="mobile_no" /></td>
<td><input type="text" name="email" /></td>
</tr>
<tr><td a align="center" colspan="4"><input type="submit" value="submit" name="submit" /></td></tr>
</form>
</table>
I also read this question Sending email filled PDF form but it didn't solve my problem.
Best Answer
After getting a lot searching and negative marks..i did solved my qus..
just edit the mypdf.php
mypdf.php