Hi folks,

I want to open a pdf stored in the database in a new window using php server side script. Actually I want store the file name in data table, which user clicks. So i need a server side script open the things in new window along with the file name... So please help me to do the same...

Recommended Answers

As far as I know, PHP cant open a new window. What you can do is to have php print the relevant link in html which when clicked directs a user to the page where the pdf file will be viewed with the appropriate parameters passed by the get method.

Jump to Post

All 2 Replies

As far as I know, PHP cant open a new window. What you can do is to have php print the relevant link in html which when clicked directs a user to the page where the pdf file will be viewed with the appropriate parameters passed by the get method.

$get_parameters="action=view&file=filename.pdf";
echo "<a href='view.php?$get_parameters' target='_blank'>click to view</a>";

For the script that receives, you can get the parameters as below

$action=$_GET['action'];
$file=$_GET['file'];

wow thanks a lot its worked fine thanks a lot sureronald


As far as I know, PHP cant open a new window. What you can do is to have php print the relevant link in html which when clicked directs a user to the page where the pdf file will be viewed with the appropriate parameters passed by the get method.

$get_parameters="action=view&file=filename.pdf";
echo "<a href='view.php?$get_parameters' target='_blank'>click to view</a>";

For the script that receives, you can get the parameters as below

$action=$_GET['action'];
$file=$_GET['file'];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.