prepare("SELECT id FROM users WHERE email = ?"); $stmt->execute([$email]); if ($stmt->fetch()) { $errors[] = 'Email già registrata.'; } else { $hash = password_hash($pass, PASSWORD_DEFAULT); $stmt = $pdo->prepare("INSERT INTO users (email, password_hash) VALUES (?, ?)"); $stmt->execute([$email, $hash]); // Invia mail di benvenuto $subject = "Benvenuto su Diplomacy Web App"; $body = "
Ciao ".htmlspecialchars($email).",
Grazie per esserti registrato su Diplomacy Web App. Ora puoi iniziare a giocare con i tuoi amici!
— Il team di Diplomacy
"; sendEmail($email, $subject, $body); // Login automatico $_SESSION['user_id'] = $pdo->lastInsertId(); $_SESSION['user_email'] = $email; header('Location: ../game/dashboard.php'); exit; } } } $page_title = 'Registrati'; include __DIR__ . '/../header.php'; ?>