Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7648793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:48:23+00:00 2026-05-31T10:48:23+00:00

i am trying to create a pdf email using data inputed into a html

  • 0

i am trying to create a pdf email using data inputed into a html form. I don’t know how to use data from a mysql database or html form to create a pdf using fpdf and email it. I am close to finishing this project i have been working on and need help closing off the deal i have a difficult html form using specially spaced tables and such trying to reproduce a excel document to a html form doing javascript calculations and now all i need to do is email this form in a pdf format using php or something using my linux webserver. please i really want to know this for myself as well. i have learned alot in the past few weeks about html,php,mysql, and javascript and i started this as a project for fun and now people want it. Sorry. And thank you all for all your help for teaching me this information. ok heres the code.

  <!DOCTYPE html>
  <html>
  <head>
 <?php
 $intro = mysql_real_escape_string($_POST['intro']);
 $hostname ="localhost";
 $db_user = "someuser";
 $db_password = "somepassword";
 $database = "form_something";
 $db_table = "FORM";
 $db = mysql_connect ($hostname, $db_user, $db_password);
 mysql_select_db($database,$db);
 ?>
  <title><h2>this is my form</h2><title>
  <?php
  if (isset($_REQUEST['Submit'])) { 
  # THIS CODE TELLS MYSQL TO INSERT THE DATA FROM THE FORM INTO MY MYSQL TABLE 
  $sql = "INSERT INTO $db_table(information) values ('".mysql_real_escape_string(stripslashes($_REQUEST['information']))."')";
  if($result = mysql_query($sql ,$db)) { 
  echo <h1>Thank you</h1>information has been entered into our database<br><img   src="http://someimage.com/here/is/the/image.jpg"';
 {
 p
 } else 
 { 
 echo "ERROR: ".mysql_error(); 
 }
 } else 
 {
 ?>
  ?>
  </head>
  <form action="pdf.php">
  <td colspan="2">type your information here<input type="text" name="information">
  <input type="submit" name="Submit" value="Submit">
  </body>
  </form>
  </html>

and the basic fpdf page pdf.php looks like this

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

class PDF extends FPDF
 {
 // Page header
function Header()
{
// Logo
$this->Image('logo.png',140,6,60);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Move to the right
$this->Cell(60);
 // Title
$this->Cell(80,10,' Form',1,0,'C');
// Line break
$this->Ln(20);
}

function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}

$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
for($i=1;$i<=40;$i++)
$pdf->Cell(0,10,'Printing line number '.$i,0,1);
$pdf->Output();
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:48:24+00:00Added an answer on May 31, 2026 at 10:48 am

    I found it to be pretty intuitive linking a HTML form with FPDF. Make your form in HTML, in this example I’m creating a Text Field and an Option Menu. Note that i create the form with the tag action="to_pdf.php" which will link the form values with php.

    <form action="to_pdf.php" method="POST">
        <p>Name</p>
        <input type="text" name="name">
    
        <p>Priority</p>
        <select name="priority" size="1">
            <option value="Low">Low</option>
            <option value="Normal">Normal</option>
            <option value="High">High</option>
            <option value="Emergency">Emergency</option>
        </select>
    
        <input type="submit" value="Send"><input type="reset" value="Clear">
    </form>
    

    Then import the form values into your php file, the one that we already stated on the HTML, to_pdf.php

    <?php
    
    $name = $_POST['name'];
    $priority = $_POST['priority'];
    
    require('fpdf.php');
    
    $pdf = new FPDF();
    $pdf->AddPage();
    
    $pdf->SetFont('Arial','B',16);
    
    $pdf->MultiCell(40,10,$name);
    $pdf->MultiCell(40,10,$priority);
    
    $pdf->Output(); 
    
    ?>
    

    After that, you only need to make sure that you have the fpdf.php file in the path you stated. And remember to run your test on a web server or on localhost so the php files actually run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create Pdf from java using iText. How Can I Add two
I am trying to create Landscape PDF using iTextSharp but It is still showing
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I am trying to create an app that converts html to a pdf doc
I am trying to create a PDF file using struts 2.Action class location is
I'm trying to create a self-contained version of pisa (html to pdf converter, latest
I'm trying to create a pdf report using iTextSharp and I'm stumped as to
I am trying to create a PDF using iTextSharp library (version 4.1.2.0). At the
I'm trying to dynamically create a PDF using the TCPDF library in a document
Trying to create a PDF file based on an XML and a file using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.