In order to save the MySql credentials in secure way and follows the below steps:
1. The root of my webserver is "/public_html/" I create a folder lets say for example /private/"
2. This location is not accesible to others externally as it does not have url being one level above the root folder.
3. In that place a config.ini at "/private/config.ini "
The config.ini contains the database login credentials:
[database]
servername = localhost
username = admin
password = password
dbname = db_main
Then create a php function within the root lets say for example at "/public_html/includ es/dbconnect.php" Contents of dbconnect.php:
<?php
$config = parse_ini_file('../private/con fig.ini');
$connection = mysqli_connect($config['server name'],$config['username'],$ config['password'],$config[' dbname']);
?>
1. The root of my webserver is "/public_html/" I create a folder lets say for example /private/"
2. This location is not accesible to others externally as it does not have url being one level above the root folder.
3. In that place a config.ini at "/private/config.ini
The config.ini contains the database login credentials:
[database]
servername = localhost
username = admin
password = password
dbname = db_main
Then create a php function within the root lets say for example at "/public_html/includ
<?php
$config = parse_ini_file('../private/con
$connection = mysqli_connect($config['server
?>
{/}
Code
No comments:
Post a Comment