Redirect a php script after sending header
<p>I have an html page with a form and a submit button.</p>

<p>Once I click submit all the form data, thanks to fpdf, gets turned into pdf.
This pdf is sent without problems to my email.</p>

<p>Building this little page everything always worked without problems and I was able to redirect my user to a thank you page without problems with this code:</p>

<pre><code>header("Location: /thank-you.php",303);
exit();
</code></pre>

<p>As soon as I've implemented the pdf file save the final redirection stopped working.</p>

<p>I've implemented the pdf save easily with fpdf:</p>

<pre><code>$pdf-&gt;Output("filename.pdf", "D");
</code></pre>

<p>And reading on stackoverflow and all the internet I've understood that you can't send two headers.</p>

<p>I thought about solving the problem with javascript so I put after the pdf generation </p>

<pre><code>echo "&lt;script language=javascript&gt;
window.location = 'thanks.html'
&lt;/script&gt;";
</code></pre>

<p>but no luck.</p>

<p>The php page simply "stops" when the browser downloads the pdf file.</p>

<p>Any chance to solve this?</p>

<p>EDIT:</p>

<p>All the suggestion I got (thanks to everybody) get me to the same point: use thank you page to handle the pdf save.
Sounds great to me.</p>

<p>I've tried preparing a thankyou.php page with a simple $pdf->Output(); in it.
It didn't work...
So I thought to use an include to my create.php (where happens all the magic: pdf creation, email sending, insert into db etc) with:</p>

<pre><code>&lt;?php
include("create.php");
$pdf-&gt;Output();
?&gt;
</code></pre>

<p>Still no luck.</p>

<p>What's wrong with my thinking?</p>
