Search code examples
phphtmlpdffpdf

After form submission, updating database as well as displaying pdf using FPDF


I'm trying to update the database and display the entered data as out put after confirmation in pdf. For the confirmation purposes I'm using

html iframe

and below the iframe I've a submit button when user press that button I'm directing it to update_db.php and that update_db.php redirects it to the fpdf showing the pdf. I'm facing the error when I click submit below the iframe It takes me to the pdf output but it isn't updating database.

Here is my code from the FORM.HTML

<form name="submission_form" method="post" action="confirmation_page.php">

and submit button

<input name="submission_form" type="submit" value="Submit">

So now the code of my confirmation_page.php

<iframe src="pdform.php" width="595" height="842" align='middle'       style="border: solid black;"></iframe>
<form name="submission_form" method="post" action="update_db.php">
  <input name="submission_form" type="submit" value="Submit">
</form>

and my "update_db.php" have the code to update the database and after that i'm using header to redirect it to pdform.php

header( 'Location: http://localhost/pdform.php' ) ; 
die();

My update_db updates the database without header but I want to redirect it to pdfrom.php when I use the header it directs it to pdform.php but doesn't update the data. I've read almost every question related to this in this website but i'm unable to do it. So what should I do to make this work.


Solution

  • You've got to be able to pass the variables from one script to another in a particular way. One way would be to add session_start at the top of your form page, and then add session_start() just inside the update_db.php file and then finally on your pdform.php as well. Then you can carry the variables from one location to another. You can then echo out those variables by using the $_SESSION['variable_name'];