generated from Templates_CodeFirst/templateHtmlCss
ajout final
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
b70b10a871
commit
ed1f86ba16
@ -0,0 +1,20 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"name": "Open cursus.html",
|
||||
"file": "c:\\Users\\Corentin\\Desktop\\site_web\\cursus.html"
|
||||
},
|
||||
{
|
||||
"type": "chrome",
|
||||
"name": "http://127.0.0.1:3000/cursus.html",
|
||||
"request": "launch",
|
||||
"url": "http://127.0.0.1:3000/cursus.html"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,26 +1,46 @@
|
||||
<?php
|
||||
// Check if the form was submitted
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Initialisation des variables d'erreur
|
||||
$errors = [];
|
||||
$data = [];
|
||||
|
||||
// Sanitize and retrieve form inputs
|
||||
$last_name = htmlspecialchars(trim($_POST['last_name']));
|
||||
$first_name = htmlspecialchars(trim($_POST['first_name']));
|
||||
$age = isset($_POST['age']) ? (int)$_POST['age'] : null; // Optional, so we check if it's set
|
||||
$gender = htmlspecialchars(trim($_POST['gender']));
|
||||
// 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'] : '';
|
||||
|
||||
// Check required fields
|
||||
if (!empty($last_name) && !empty($first_name)) {
|
||||
// Process form data (e.g., store in a database, display, etc.)
|
||||
echo "<h1>Form Submitted Successfully!</h1>";
|
||||
echo "<p>Last Name: " . $last_name . "</p>";
|
||||
echo "<p>First Name: " . $first_name . "</p>";
|
||||
echo "<p>Age: " . ($age !== null ? $age : 'Not provided') . "</p>";
|
||||
echo "<p>Gender: " . $gender . "</p>";
|
||||
} else {
|
||||
// Handle missing required fields
|
||||
echo "<p>Error: First name and last name are required.</p>";
|
||||
// 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 "<p>No form was submitted.</p>";
|
||||
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>";
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in new issue