generated from Templates_CodeFirst/templateHtmlCss
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
2.4 KiB
47 lines
2.4 KiB
<?php
|
|
// Initialisation des variables d'erreur
|
|
$errors = [];
|
|
$data = [];
|
|
|
|
// Vérification des champs obligatoires
|
|
if ($_SERVER['REQUEST_METHOD'] === 'GET' || $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$data['name'] = !empty($_REQUEST['name']) ? trim($_REQUEST['name']) : null;
|
|
$data['email'] = !empty($_REQUEST['email']) ? trim($_REQUEST['email']) : null;
|
|
$data['message'] = !empty($_REQUEST['message']) ? trim($_REQUEST['message']) : null;
|
|
$data['phone'] = isset($_REQUEST['phone']) ? trim($_REQUEST['phone']) : '';
|
|
$data['reason'] = isset($_REQUEST['reason']) ? $_REQUEST['reason'] : '';
|
|
$data['schedule'] = isset($_REQUEST['schedule']) ? $_REQUEST['schedule'] : '';
|
|
$data['first_request'] = isset($_REQUEST['first_request']) ? $_REQUEST['first_request'] : '';
|
|
|
|
// Vérifications des champs obligatoires
|
|
if (!$data['name']) $errors[] = "Le champ 'Nom' est obligatoire.";
|
|
if (!$data['email']) $errors[] = "Le champ 'Adresse de courriel' est obligatoire.";
|
|
if (!$data['message']) $errors[] = "Le champ 'Message' est obligatoire.";
|
|
|
|
// Validation de l'adresse email
|
|
if ($data['email'] && !filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
|
|
$errors[] = "Le format de l'adresse de courriel est invalide.";
|
|
}
|
|
|
|
// Affichage des erreurs ou récapitulatif
|
|
if ($errors) {
|
|
echo "<h2>Erreurs dans le formulaire :</h2><ul>";
|
|
foreach ($errors as $error) {
|
|
echo "<li>" . htmlspecialchars($error) . "</li>";
|
|
}
|
|
echo "</ul>";
|
|
echo "<a href='index.html'>Retour au formulaire</a>";
|
|
} else {
|
|
echo "<h2>Récapitulatif de votre demande</h2>";
|
|
echo "<p><strong>Nom :</strong> " . htmlspecialchars($data['name']) . "</p>";
|
|
echo "<p><strong>Adresse de courriel :</strong> " . htmlspecialchars($data['email']) . "</p>";
|
|
echo "<p><strong>Numéro de téléphone :</strong> " . htmlspecialchars($data['phone']) . "</p>";
|
|
echo "<p><strong>Motif de contact :</strong> " . htmlspecialchars($data['reason']) . "</p>";
|
|
echo "<p><strong>Créneau horaire :</strong> " . htmlspecialchars($data['schedule']) . "</p>";
|
|
echo "<p><strong>Première demande :</strong> " . ($data['first_request'] === 'yes' ? 'Oui' : 'Non') . "</p>";
|
|
echo "<p><strong>Message :</strong> " . nl2br(htmlspecialchars($data['message'])) . "</p>";
|
|
echo "<p>Votre demande a été prise en compte et sera étudiée.</p>";
|
|
}
|
|
}
|
|
?>
|