mirror of
https://codeberg.org/ThisIsMiseryy/techstore
synced 2026-05-14 14:52:04 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
5fa3aa7c24
|
|||
|
0e393b9318
|
|||
|
1823553f55
|
|||
|
cfcc449614
|
|||
|
a8690feafc
|
|||
|
3ffa3435a4
|
@@ -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
|
||||||
+7
-6
@@ -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
|
||||||
$conn = mysqli_connect($host, $username, $password, $database);
|
try{
|
||||||
|
$conn = mysqli_connect($host, $username, $password, $database);
|
||||||
// Controllo connessione
|
}
|
||||||
if ($conn->connect_error) {
|
catch(Exception $e) {
|
||||||
die("Connessione fallita: " . $conn->connect_error);
|
error_log("Errore connessione database: " . $e->getMessage());
|
||||||
|
die("Errore di connessione al database. Riprova più tardi.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opzionale: impostare charset
|
// Opzionale: impostare charset
|
||||||
|
|||||||
+43
-40
@@ -1,3 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
include 'db_conf.php';
|
||||||
|
|
||||||
|
$error = '';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$email = $_POST['email'];
|
||||||
|
$password = $_POST['password'];
|
||||||
|
|
||||||
|
$sql = "SELECT UserID, Name, Surname, Password, Role FROM Users WHERE Email = ?";
|
||||||
|
if ($stmt = $conn->prepare($sql)) {
|
||||||
|
$stmt->bind_param("s", $email);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->store_result();
|
||||||
|
|
||||||
|
if ($stmt->num_rows > 0) {
|
||||||
|
$stmt->bind_result($user_id, $name, $surname, $hashed_password, $role);
|
||||||
|
$stmt->fetch();
|
||||||
|
|
||||||
|
if (password_verify($password, $hashed_password)) {
|
||||||
|
$_SESSION['id'] = $user_id;
|
||||||
|
$_SESSION['name'] = $name;
|
||||||
|
$_SESSION['surname'] = $surname;
|
||||||
|
$_SESSION['role'] = $role;
|
||||||
|
header('Location: index.php');
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
$error = 'Credenziali errate.';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error = 'Credenziali errate.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->close();
|
||||||
|
} else {
|
||||||
|
$error = 'Errore nel database.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="it">
|
<html lang="it">
|
||||||
<head>
|
<head>
|
||||||
@@ -7,46 +50,6 @@
|
|||||||
<link rel="stylesheet" href="assets/style.css">
|
<link rel="stylesheet" href="assets/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
|
||||||
session_start();
|
|
||||||
include 'db_conf.php';
|
|
||||||
|
|
||||||
$error = '';
|
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
$email = $_POST['email'];
|
|
||||||
$password = $_POST['password'];
|
|
||||||
|
|
||||||
$sql = "SELECT UserID, Name, Surname, Password, Role FROM Users WHERE Email = ?";
|
|
||||||
if ($stmt = $conn->prepare($sql)) {
|
|
||||||
$stmt->bind_param("s", $email);
|
|
||||||
$stmt->execute();
|
|
||||||
$stmt->store_result();
|
|
||||||
|
|
||||||
if ($stmt->num_rows > 0) {
|
|
||||||
$stmt->bind_result($user_id, $name, $surname, $hashed_password, $role);
|
|
||||||
$stmt->fetch();
|
|
||||||
|
|
||||||
if (password_verify($password, $hashed_password)) {
|
|
||||||
$_SESSION['id'] = $user_id;
|
|
||||||
$_SESSION['name'] = $name;
|
|
||||||
$_SESSION['surname'] = $surname;
|
|
||||||
$_SESSION['role'] = $role;
|
|
||||||
header('Location: index.php');
|
|
||||||
exit();
|
|
||||||
} else {
|
|
||||||
$error = 'Credenziali errate.';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$error = 'Credenziali errate.';
|
|
||||||
}
|
|
||||||
|
|
||||||
$stmt->close();
|
|
||||||
} else {
|
|
||||||
$error = 'Errore nel database.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<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>
|
||||||
|
|||||||
Reference in New Issue
Block a user