TCPDF - Create PDF from Form Values and Link to PDF Download
Hi
I am working on a payment module and I wish to create an option to allow the user download a PDF version of their Receipt.
At the moment, I am capturing the form values and displaying a receipt of their payment on the page in HTML, like:
<p>Receipt for Purchase:</p>
<ul>
<li>First Name: $pfirstname </li>
<li>Last Name: $plastname</li>
<li>Address 1: $paddress1</li>
<li>Address 2: $paddress2</li>
<li>Town/Village: $ptownvillage</li>
<li>Postcode: $peircodepostcode</li>
<li>Mobile: $mobile</li>
<li>Email: $email</li>
</ul>
How do I create a link at the bottom of this to allow them download or open a PDF version of this with the form values?
Attached is the PHP file which uses TCPDF to create a blank PDF document on the server, but without the form values.
Thanks for your excellent response and clarity. I have followed all the steps and its all working up to the point of trying to create the temporary JSON file.
I get the following message: Warning: file_put_contents(2017-03-09MyName.json): failed to open stream: Permission denied
The suggested solutions elsewhere are to set the folder permissions to 777 but surely this is a huge security risk?
No, it's not really a huge security risk, and the permissions do not need to be 777. On my server, I write things all the time. The directories have perms set to rwxr-xr-x (0755) and the files seem to get rw-r--r-- (I think that's 0644) more or less automatically.
F Grace
ASKER
Excellent..got it working now, many thanks
F Grace
ASKER
Excellent answer, very detailed and easy to follow. Thanks for your help :)
?