Aggiornamento con sorgente prof

This commit is contained in:
2026-03-31 09:35:40 +02:00
parent 554631795d
commit 338b64662b
7 changed files with 579 additions and 72 deletions
+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>