Jump to content

Importance of placing db connection details in different file/folder?


shane85

Recommended Posts

I was reading somewhere its very important to keep the database connection details (login pass) etc in the main directory so that hackers cant get the info and corrupt the database....is this true?? If so, where should these details be kept on the server???

 

Thank you

Kind of..somewhat important.

 

IE...you create a directory called settings and create a file call db.php.  In the db.php file you will add the connection db stuff.

 

You will then call it from the file you need it from with:

 

<?php include('settings/db.php'); ?>

 

It mainly keeps your code shorter so you don't have to keep adding the connection strings in each file, you simply need to call it.

but how is this any safer I dont understand? couldnt they essentially hack this file? or is the point of it so if they hack the others they cant see it, where as only having it in the 1 file limits the chances??

 

I understand that it cleans up the code though, for sure

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.