Generate a PDF and write data to the bank in the same form

0

I have a program that takes the name and email of the client to register in the bank and generate a pdf with this data. But I can not send the registration data to the file that generates the pdf. Either the register works in the bank or the pdf works. I've already used Ajax to submit to different files but it does not work. The ideal would be to generate the pdf after saving this data in the bank but also does not work.

Form:

<form action="incluirProfessor.php" method="POST"> 
<!--Entrada dados --> 
<label for="nomeprof"> Nome: </label> <input name="nomeprof" type="text"/>
<label for="emailprof">eMail: </label> <input name="emailprof" type="email"/>
<input type="submit" name="Convidar" value="Convidar" /> 
</form>

Include:

  // incluirProfessor.php

  require 'conexao.php';
  if (isset($_POST["Convidar"])) {

  mysqli_query($con, "SET NAMES 'utf8'");

  $nome  = $_POST["nomeprof"];
  $email = $_POST["emailprof"];

  // Guardando a instrução sql para inclusao
  $sqlinc = "insert into professor(Prof_Nome,Prof_Email) values ('$nome','$email')";

  // submetendo inserção à conexão, se algo der errado paramos a execução com DIE

  if ($con->query($sqlinc) === TRUE) {
  echo "<script>alert('Cadastro realizado com sucesso!'); </script>";
  } else {
  echo "<script>alert('Ocorreu algum erro! Seu cadastro não foi concluído com sucesso.');</script>";
  echo "Error deleting record: " .$con->error;
  }
  mysqli_close($con); 
  exit;
}

PDF:

<?php   
use Dompdf\Dompdf; 
require_once("dompdf/autoload.inc.php"); 
$dompdf = new DOMPDF(); 
$nomeprof = $_POST["nomeprof"]; 
$emailprof = $_POST["emailprof"]; 
$data_envio = date('d/m/Y'); 
$from = "[email protected]"; 
$subject = "Convite para o sistema InfoQT"; 
$site = "www.infoqt.com.br"; 
$dompdf->load_html("Mensagem enviada"); 
$dompdf->render(); //Exibibir a página 
$dompdf->stream( "relatorio_celke.pdf", array( "Attachment" => false //Para realizar o download somente alterar para true ) ); ?>
    
asked by anonymous 30.05.2018 / 00:35

0 answers