🔒️ Improved and fixed security issues by adding .env file for DB connection and loading class.

This commit is contained in:
Florian Sylvain
2021-09-24 22:37:00 +02:00
parent a05438ab76
commit f56ba7e3c8
3 changed files with 51 additions and 6 deletions
+4 -6
View File
@@ -1,15 +1,13 @@
<?php
require_once('dotEnv.php');
(new DotEnv(__DIR__ . '/../.env'))->load();
class conf
{
private pdo $pdo;
public function __construct()
{
$this->pdo = new PDO('mysql:host=localhost;dbname=projet_prog_web', 'root', 'root');
}
public function getPDO() : pdo {
return $this->pdo;
return new PDO('mysql:host=localhost;dbname=' . getenv('DBNAME'), getenv('USERNAME'), getenv('PASSWORD'));
}
}