Hi frens,
I have already asked this question in another thread, but then felt this issue was irrelevent to that thread.
I have a requirement to generate a invoice in pdf format and download it.
i have a dynamic form, where user can enter date, choose option from dropdown, add/remove rows depending upon no. of products.
code in abc.php
<form action="abc.php" method="POST">
Enter ur name<input type="text" name="chk">
<input type="submit" value="save" name="submit">
</form>
i ve written the code to save the user input into db in the same file. it works fine.
to generate pdf, i looked around in internet and found pdflib lite, r&os, fpdf to generate pdf, i decided to use fpdf(hoping that this has good support from its makers),i generated some pdfs to understand how it works and its working fine.
now to generate the invoice, i wrote something like this in abc.php
<?php
/*
codes to save the user input values to db(this works fine)
*/
require('../fpdf.php');
class PDF extends FPDF
{
//some functions
}
$pdf=new PDF();
//
//more pdf codes
//
$pdf->Output("myfile.pdf");
if($result == true)
echo "<script>window.location.href=xyz</script>";
else
die("error");
?>
if i run this pdf separately in genratepdf.php it runs fine, however i have lots of user input to display in the pdf, and i could not figure out how to pass the values to different file, cos i already have a submit button and action=abc.php,so i wrote it in the same abc.php file and this doesnt generate pdf.
so my doubts are is it ok to redirect the page after "$pdf->Output();" ??
if not, will i have to keep this code in different file?? then how do i pass all the user input values(minimum 15- max depends on the no. of products)to that file?? i dont think using href is a good option, at the same time i dont know any other alternative.:@
please suggest some alternative for this..
Also, i wanted some guidance on how to get the dialogue box asking to open the file or save the file, and user can choose to save the file to download to the system.
thanks for your time and suggestion.