Aggiunta supporto variabili d'ambiente per parametri connessione DB

This commit is contained in:
2026-04-09 08:33:28 +02:00
parent 9bec64e811
commit 8845b83634
3 changed files with 10 additions and 5 deletions
+4
View File
@@ -0,0 +1,4 @@
DB_HOST=localhost
DB_USERNAME=techstore
DB_PASSWORD=dioporco
DB_DATABASE=TechStore
+1
View File
@@ -1,3 +1,4 @@
img/*
!img/example/
!img/logo.png
.env
+4 -4
View File
@@ -1,9 +1,9 @@
<?php
// Configurazione connessione database
$host = 'localhost';
$username = 'techstore';
$password = 'dioporco';
$database = 'TechStore';
$host = getenv("DB_HOST") ?: 'localhost';
$username = getenv("DB_USERNAME") ?:'root';
$password = getenv("DB_PASSWORD") ?: '';
$database = getenv("DB_DATABASE") ?: 'TechStore';
// Creazione connessione
$conn = mysqli_connect($host, $username, $password, $database);