Question

I need to store mysql database access details in a flat file format. I.e in a .txt and the details on separate lines. I can easily do this, but then there is a big security flaw that the details.txt file can easily be navigated to and read by anyone.

How can I make it so that this is not possible.

I tired to save the files as a .php but then it does not read the lines with the command.

$lines = file('details.php');
Was it helpful?

Solution

In your htaccess file you can add

<Files "database.txt">
    Order Allow,Deny
    Deny from all
</Files>

Which will prevent people accessing that file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top