Compare commits

..

3 Commits

Author SHA1 Message Date
AndreStork 8abbf13c68 Fix ritorno alla home in login e logout 2026-03-31 09:38:26 +02:00
AndreStork 019d9e0764 Migrazione home.php in index.php 2026-03-31 09:36:51 +02:00
AndreStork 338b64662b Aggiornamento con sorgente prof 2026-03-31 09:35:40 +02:00
6 changed files with 565 additions and 58 deletions
+125 -11
View File
@@ -1,27 +1,141 @@
<!DOCTYPE html>
<html lang="it">
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gestione aeroporto</title>
<link rel="stylesheet" href="style.css">
<title>Document</title>
<style>
.no{
/* Reset e Font */
body {
font-family: 'Segoe UI', Arial, sans-serif;
background-color: #80a9e7;
color: #333;
display: flex;
flex-direction: column;
align-items: center;
padding: 40px 20px;
margin: 0;
}
/* Contenitore per Form e Tabelle */
.box {
background: #fff;
padding: 25px;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 500px;
/* Più stretto per i form */
margin-bottom: 20px;
}
/* Estensione per la tabella (più larga) */
.wide-box {
max-width: 800px;
}
h2 {
margin-top: 0;
color: #1c1e21;
text-align: center;
}
/* Stile Input e Bottoni */
input {
width: 100%;
padding: 12px;
margin: 10px 0;
border: 1px solid #ddd;
border-radius: 6px;
box-sizing: border-box;
/* Importante per il padding */
}
button {
margin: 10px 10px 10px 10px;
width: 350px;
width: 100%;
padding: 12px;
background-color: #007bff;
border: none;
border-radius: 6px;
color: white;
font-weight: bold;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #0056b3;
}
/* Tabella */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
text-align: left;
padding: 12px;
border-bottom: 1px solid #eee;
}
th {
background-color: #f8f9fa;
color: #555;
}
tr:hover {
background-color: #fafafa;
}
/* Link e messaggi */
a {
color: #007bff;
text-decoration: none;
font-size: 14px;
}
a:hover {
text-decoration: underline;
}
.msg {
padding: 10px;
margin-bottom: 15px;
border-radius: 5px;
text-align: center;
font-size: 14px;
}
.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
</style>
</head>
<body>
<div class="no">
<h2>Gestione Aeroporto</h2>
<a href="login.php"><button>Login</button></a><br>
<a href="register.php"><button>Registrati</button></a><br>
<a href="https://cdn.mtdv.me/video/rick.mp4"><button>Logout</button></a><br>
<center>
<h1>Gestione Aeroporto</h1>
</center>
<!-- Ho rimosso il </center> orfano e corretto i doppi apici -->
<div style="width: 100%; max-width: 300px;">
<button class="btn-1" onclick="window.location.href='login.php'">Login</button><br><br>
<button class="btn-2" onclick="window.location.href='registrati.php'">Registrati</button><br><br>
<button class="btn-3" onclick="window.location.href='logout.php'">Logout</button>
</div>
</body>
</html>
+119 -18
View File
@@ -1,24 +1,125 @@
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - Accesso aeroporto</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php
if(isset($_POST['username']) || isset($_POST['password'])){
echo "PUPPAMI LA FAVA<br><br>";
// 1. IL PHP SEMPRE IN ALTO (PRIMA DI OGNI HTML/CSS)
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
require '_db_config.php'; // Assicurati che il file si chiami così e che la variabile sia $conn
$messaggio_errore = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// RIMOSSO il controllo su 'email' perché nel form non c'è
if (isset($_POST['username']) && isset($_POST['password'])) {
$user = $_POST['username'];
$pass = $_POST['password'];
// CONTROLLA SE LA TABELLA È 'utente' O 'utenti'
$sql = "SELECT password FROM utente WHERE username = ?";
$stmt = mysqli_prepare($conn, $sql);
if ($stmt) {
mysqli_stmt_bind_param($stmt, "s", $user);
mysqli_stmt_execute($stmt);
$risultato = mysqli_stmt_get_result($stmt);
$riga = mysqli_fetch_assoc($risultato);
if ($riga && password_verify($pass, $riga['password'])) {
$_SESSION['loggato'] = true;
$_SESSION['utente'] = $user;
// Ora il reindirizzamento funzionerà perché non c'è HTML sopra
header("Location: visualizza_dati.php");
exit;
} else {
$messaggio_errore = "Username o Password non validi!";
}
mysqli_stmt_close($stmt);
} else {
$messaggio_errore = "Errore nel database: " . mysqli_error($conn);
}
}
}
?>
<form class="form-group" action="" method="POST">
<h4 style="text-align: center;">Accedi</h4>
<label for="username">Nome utente</label>
<input type="text" id="username" name="username">
<label for="password">Password</label>
<input type="password" id="password" name="password">
<input type="submit" value="Accedi">
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<title>Login</title>
<style>
/* Il tuo CSS qui (lo stesso che hai postato) */
body {
font-family: 'Segoe UI', Arial, sans-serif;
background-color: #f0f2f5;
display: flex;
flex-direction: column;
align-items: center;
padding: 40px;
}
.box {
background: #fff;
padding: 25px;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
}
input {
width: 100%;
padding: 12px;
margin: 10px 0;
border: 1px solid #ddd;
border-radius: 6px;
box-sizing: border-box;
}
button {
width: 100%;
padding: 12px;
background-color: #007bff;
border: none;
border-radius: 6px;
color: white;
font-weight: bold;
cursor: pointer;
}
.error {
background: #f8d7da;
color: #721c24;
padding: 10px;
border-radius: 5px;
margin-bottom: 15px;
text-align: center;
}
</style>
</head>
<body>
<div class="box">
<h2>Accedi</h2>
<!-- Visualizza l'errore se presente -->
<?php if ($messaggio_errore): ?>
<div class="error"><?php echo $messaggio_errore; ?></div>
<?php endif; ?>
<form method="post" action="login.php">
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Accedi</button>
</form>
<p style="text-align:center; margin-top:15px;">
<a href="index.php" style="color:#007bff; text-decoration:none;">Torna alla Home</a>
</p>
</div>
</body>
</html>
+6
View File
@@ -0,0 +1,6 @@
<?php
session_start();
session_unset();
session_destroy();
header("Location: index.php");
exit;
-28
View File
@@ -1,28 +0,0 @@
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Registrazione - Gestione aeroporto</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
echo "PUPPAMI LA FAVA<br><br>";
}
?>
<form class="form-group" action="" method="POST">
<h4 style="text-align: center;">Registrati</h4>
<label for="username">Nome utente</label>
<input type="text" id="username" name="username">
<label for="email">Indirizzo e-mail</label>
<input type="email" id="email" name="email">
<label for="password">Password</label>
<input type="password" id="password" name="password">
<label for="passwordConfirm">Conferma password</label>
<input type="password" id="passwordConfirm" name="passwordConfirm">
<input type="submit" value="Registrati">
</form>
</body>
</html>
+162
View File
@@ -0,0 +1,162 @@
<head>
<style>
/* Reset e Font */
body {
font-family: 'Segoe UI', Arial, sans-serif;
background-color: #f0f2f5;
color: #333;
display: flex;
flex-direction: column;
align-items: center;
padding: 40px 20px;
margin: 0;
}
/* Contenitore per Form e Tabelle */
.box {
background: #fff;
padding: 25px;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 500px;
/* Più stretto per i form */
margin-bottom: 20px;
}
/* Estensione per la tabella (più larga) */
.wide-box {
max-width: 800px;
}
h2 {
margin-top: 0;
color: #1c1e21;
text-align: center;
}
/* Stile Input e Bottoni */
input {
width: 100%;
padding: 12px;
margin: 10px 0;
border: 1px solid #ddd;
border-radius: 6px;
box-sizing: border-box;
/* Importante per il padding */
}
button {
width: 100%;
padding: 12px;
background-color: #007bff;
border: none;
border-radius: 6px;
color: white;
font-weight: bold;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #0056b3;
}
/* Tabella */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
text-align: left;
padding: 12px;
border-bottom: 1px solid #eee;
}
th {
background-color: #f8f9fa;
color: #555;
}
tr:hover {
background-color: #fafafa;
}
/* Link e messaggi */
a {
color: #007bff;
text-decoration: none;
font-size: 14px;
}
a:hover {
text-decoration: underline;
}
.msg {
padding: 10px;
margin-bottom: 15px;
border-radius: 5px;
text-align: center;
font-size: 14px;
}
.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
</style>
</head>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once '_db_config.php';
if (($_SERVER['REQUEST_METHOD'] ?? '') == 'POST') {
if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password'])) {
$user = $_POST['username'];
$email = $_POST['email'];
$pass = password_hash($_POST['password'], PASSWORD_DEFAULT);
// 1. Prepariamo la query
$sql = "INSERT INTO utente (username, email, password) VALUES (?, ?, ?)";
$stmt = mysqli_prepare($conn, $sql);
// 2. Colleghiamo i parametri (sss = 3 stringhe)
mysqli_stmt_bind_param($stmt, "sss", $user, $email, $pass);
// 3. Eseguiamo lo statement
if (mysqli_stmt_execute($stmt)) {
echo "Registrazione avvenuta! <a href='login.php'>Accedi qui</a>";
} else {
echo "Errore nell'inserimento: " . mysqli_error($conn);
}
}
// 4. Chiudiamo lo statement
mysqli_stmt_close($stmt);
}
?>
<form action="" method="post">
<input type="text" name="username" placeholder="Username" required><br>
<input type="email" name="email" placeholder="Email" required><br>
<input type="password" name="password" placeholder="Password" required><br>
<button type="submit">Registrati</button>
</form>
+152
View File
@@ -0,0 +1,152 @@
<head>
<style>
/* Reset e Font */
body {
font-family: 'Segoe UI', Arial, sans-serif;
background-color: #f0f2f5;
color: #333;
display: flex;
flex-direction: column;
align-items: center;
padding: 40px 20px;
margin: 0;
}
/* Contenitore per Form e Tabelle */
.box {
background: #fff;
padding: 25px;
border-radius: 10px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 500px;
/* Più stretto per i form */
margin-bottom: 20px;
}
/* Estensione per la tabella (più larga) */
.wide-box {
max-width: 800px;
}
h2 {
margin-top: 0;
color: #1c1e21;
text-align: center;
}
/* Stile Input e Bottoni */
input {
width: 100%;
padding: 12px;
margin: 10px 0;
border: 1px solid #ddd;
border-radius: 6px;
box-sizing: border-box;
/* Importante per il padding */
}
button {
width: 100%;
padding: 12px;
background-color: #007bff;
border: none;
border-radius: 6px;
color: white;
font-weight: bold;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #0056b3;
}
/* Tabella */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
text-align: left;
padding: 12px;
border-bottom: 1px solid #eee;
}
th {
background-color: #f8f9fa;
color: #555;
}
tr:hover {
background-color: #fafafa;
}
/* Link e messaggi */
a {
color: #007bff;
text-decoration: none;
font-size: 14px;
}
a:hover {
text-decoration: underline;
}
.msg {
padding: 10px;
margin-bottom: 15px;
border-radius: 5px;
text-align: center;
font-size: 14px;
}
.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
</style>
</head>
<?php
session_start();
require '_db_config.php';
// Se la sessione non è attiva, torna al login
if (!isset($_SESSION['loggato'])) {
header("Location: login.php");
exit;
}
// Query semplice (senza parametri esterni non serve il prepared statement)
$sql = "SELECT username, email FROM utente";
$query_risultato = mysqli_query($conn, $sql);
?>
<h2>Benvenuto, <?php echo htmlspecialchars($_SESSION['utente']); ?></h2>
<a href="logout.php">Disconnetti</a>
<table border="1" style="width:100%; margin-top:20px; text-align:left;">
<tr>
<th>ID</th>
<th>Username</th>
<th>Email</th>
</tr>
<?php while ($riga = mysqli_fetch_assoc($query_risultato)): ?>
<tr>
<td><?php echo $riga['id']; ?></td>
<td><?php echo htmlspecialchars($riga['username']); ?></td>
<td><?php echo htmlspecialchars($riga['email']); ?></td>
</tr>
<?php endwhile; ?>
</table>