Open new window


I am wondering how to go about openign another window on a button being submitted, so that i can generate my .pdf file there as opposed to creating the pdf in the same window that the submit button was pressed 9hope that made sense)

ie something like

if (isset ($_POST[‘confirm’]) and $_POST[‘confirm’] == ‘Yes’)
open new window;
include pdf.php;

Not that it matters to much, I am using Fpdf to create the pdf’s.

Thanks in advance.

I would suggest that you set the form action to point to pdf.php

In pdf.php, make sure you set the correct headers (content type and charset). This will mean that you pdf is treated as a download and the user remains on the same page.

If you want to display the pdf in the web browser, then you can use javscript to open a new window, you wont be able to do it in php.

Thank you again Mr Wooster.

I opted to change the output to a file, not the PDF itself. which of course removes the need for the new window.

I dont suppose you know how I would redirect to a different page once the PDF has been saved? I toyed with putting an include after the output() from FDPF. but that doesnt seem to function.

Hmm… you would not be able to do it from the pdf script, but there might be some javascript you can use.

Another way to do it would be to redirect the user to a landing page with something like:

Your download is now ready, click here to begin your download.

The href would link to the pdf script.

I think I like that method more, as it also kinda solves another issue I have in how to navigate back to a menu without tempting another press of the submit button !

Thank you again MrW