This tutorial explains how to safely hide away PDF files from public access using htaccess, but then having a PHP file run its own authorization to allow access to the file without the Network Password dialog box. The PDF file will be displayed in the browser (if the user has acrobat reader) or promoted to download the pdf file if the user doesn't have acrobat reader. This is perfect for when you want to restrict PDF files to authorized eyes only. This simple to use tutorial will have you up and running in a few minutes, one page of info with full source code, and working examples.
Connecting to a database requires that passwords be included in the script at some point. This information maybe exposed if you do not wrap your PHP scripts. Protecting your scripts from prying eyes is called "wrapping." When you wrap a script, it is called by another script thathides your script and performs a number of security checks to ensure only authorized use is made of it. This article covers how to use a script wrapper.