jonyetter33 0 Newbie Poster

I'm attempting to create a form that will eventually take user submitted information to create a pdf and email it to them with a pdf attachment. I got through making the form, and how I've been getting the information from page to page (its about a 4 page little form) is by using

<?php
  foreach($_POST as $key=>$value){
    if ($key!="submit"){
      $value=htmlentities(stripslashes(strip_tags($value)));
      echo "\t<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
    }
  }
?>


<?php

and this is keeping the submitted information hidden on each page, and then the last page it is all "echo"ed back to verify that the information is correct.

Where I'm having an issue is getting the email from the form to be posted in the

$to = echo $_POST["email"];

As you may be able to tell I'm very new to all this but would appreciate your time and help!

Thanks


The whole code that I am using that I took from a tutorials

<?php
  foreach($_POST as $key=>$value){
    if ($key!="submit"){
      $value=htmlentities(stripslashes(strip_tags($value)));
      echo "\t<input type=\"hidden\" name=\"$key\" value=\"$value\">\n";
    }
  }
?>

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

$pdf = new FPDF();
 
)
$pdf->AddPage();
$pdf->SetFont("Arial","B",14);
$pdf->Cell(40,10, "this is a pdf example");
 

$to = echo $_POST["email"];
$from = "jonyetter33@gmail.com"; 
$subject = "Privacy for Police PDF"; 
$message = "<p>Thank you. Please see attachment.</p>";
 

$separator = md5(time());
 

$eol = PHP_EOL;
 

$filename = "Privacy for Police Letter.pdf";
 

$pdfdoc = $pdf->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));
 
 

$headers  = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol; 
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol; 
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;
 

$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;
 

$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; 
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";
 

mail($to, $subject, "", $headers);
 
?>

<?php echo $_POST["first_name"]; ?> Thank you, an email has been sent to you with your pdf attached

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.