mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-10-19 04:53:51 +02:00
🔒️ Improved and fixed security issues by adding .env file for DB connection and loading class.
This commit is contained in:
1 parent
a05438ab76
commit
f56ba7e3c8
3 files changed
+51
-6
No files matched your search
@@ -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