mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-08-19 19:53:18 +02:00
🔒️ Improved and fixed security issues by adding .env file for DB connection and loading class.
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user