6 Commits

3 changed files with 68 additions and 46 deletions
+18
View File
@@ -0,0 +1,18 @@
services:
techstore:
image: andrestork/techstore:dev
ports:
- 8069:80
environment:
DB_HOST: mariadb
DB_USERNAME: techstore
DB_PASSWORD: changeme
DB_DATABASE: TechStore
mariadb:
image: mariadb
restart: always
environment:
MARIADB_ROOT_PASSWORD: changemeplease
MARIADB_USER: techstore
MARIADB_PASSWORD: changeme
MARIADB_DATABASE: TechStore
+6 -5
View File
@@ -5,12 +5,13 @@ $username = getenv("DB_USERNAME") ?:'techstore';
$password = getenv("DB_PASSWORD") ?: 'dioporco'; $password = getenv("DB_PASSWORD") ?: 'dioporco';
$database = getenv("DB_DATABASE") ?: 'TechStore'; $database = getenv("DB_DATABASE") ?: 'TechStore';
// Creazione connessione // Creazione e gestione eccezioni connessione
try{
$conn = mysqli_connect($host, $username, $password, $database); $conn = mysqli_connect($host, $username, $password, $database);
}
// Controllo connessione catch(Exception $e) {
if ($conn->connect_error) { error_log("Errore connessione database: " . $e->getMessage());
die("Connessione fallita: " . $conn->connect_error); die("Errore di connessione al database. Riprova più tardi.");
} }
// Opzionale: impostare charset // Opzionale: impostare charset
+12 -9
View File
@@ -1,12 +1,3 @@
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - TechStore</title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<?php <?php
session_start(); session_start();
include 'db_conf.php'; include 'db_conf.php';
@@ -46,7 +37,19 @@
$error = 'Errore nel database.'; $error = 'Errore nel database.';
} }
} }
$conn->close();
?> ?>
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - TechStore</title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<form action="" method="POST"> <form action="" method="POST">
<h2>Login</h2> <h2>Login</h2>
<label for="email">Indirizzo e-mail:</label> <label for="email">Indirizzo e-mail:</label>