prepare("SELECT id FROM compte WHERE email = :email LIMIT 1"); $stmt->execute(['email' => $email]); $compte = $stmt->fetch(); if ($compte) { $code = random_int(100000, 999999); $_SESSION['reset_email'] = $email; $_SESSION['reset_code'] = (string) $code; $_SESSION['reset_time'] = time(); $_SESSION['reset_ttl'] = 600; $_SESSION['reset_attempts'] = 0; $sujet = $translations['mail_sujet_code'] ?? 'Code de réinitialisation'; $codeHtml = htmlspecialchars((string) $code, ENT_QUOTES, 'UTF-8'); $html = "
" . htmlspecialchars($translations['mail_bonjour'] ?? 'Bonjour', ENT_QUOTES, 'UTF-8') . "

" . htmlspecialchars($translations['mail_phrase_code'] ?? 'Voici votre code de réinitialisation :', ENT_QUOTES, 'UTF-8') . "

" . $codeHtml . "

" . htmlspecialchars($translations['mail_phrase_validite'] ?? 'Ce code est valable pendant un temps limité.', ENT_QUOTES, 'UTF-8') . "

"; $text = strip_tags( ($translations['mail_bonjour'] ?? 'Bonjour') . "\n\n" . ($translations['mail_phrase_code'] ?? 'Voici votre code de réinitialisation :') . "\n" . $code . "\n" . ($translations['mail_phrase_validite'] ?? 'Ce code est valable pendant un temps limité.') . "\n\n" . ($translations['mail_signature'] ?? 'USLUGI.FR') ); list($ok, $err) = uslugi_mail($email, $sujet, $html, $text); if (! $ok) { error_log("Reset code mail NOT sent to $email : $err"); // on reste neutre côté utilisateur } // On peut rediriger seulement si le compte existe header("Location: verifier_code.php"); exit; } // Email inconnu → message neutre, pas de détail $message = $translations['mdp_oublie_message_neutre'] ?? 'Si un compte existe pour cette adresse, un code a été envoyé.'; $messageType = 'success'; } } ?> <?php echo htmlspecialchars($translations['mdp_oublie_title'] ?? 'Mot de passe oublié', ENT_QUOTES, 'UTF-8') ?>