You can use the function include
to include other files in your script. If you want to terminate processing when the file is not available you can use require
Put the login information in another file and include that in all the files you need your database.
give that file the extention .php, that way your password will not be exposed when someone finds that file.