Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $nomError = '';
- $prenomError = '';
- $emailError = '';
- $phoneError = '';
- $listeError = '';
- $messageError = '';
- if (isset($_POST['isFormSubmitted']))
- {
- $nom = $_POST['nom'];
- $prenom = $_POST['prenom'];
- $email = $_POST['email'];
- $phone = $_POST['phone'];
- $liste = $_POST['liste'];
- $message = $_POST['message'];
- if (empty($nom) === true)
- {
- $nomError = '<br> Erreur : champ invalide';
- }
- if (empty($prenom) === true)
- {
- $prenomError = '<br> Erreur : champ invalide';
- }
- if (empty($email) === true)
- {
- $prenomError = '<br> Erreur : champ invalide';
- }
- if (empty($phone) === true)
- {
- $phoneError = '<br> Erreur : champ invalide';
- }
- if (empty($liste) === true)
- {
- $listeError = '<br> Erreur : champ invalide';
- }
- if (empty($message) === true)
- {
- $messageError = '<br> Erreur : champ invalide';
- }
- $variable = filter_var( $email,FILTER_VALIDATE_EMAIL);
- if ($variable === false)
- {
- $emailError = 'Mauvais email';
- }
- if (
- empty($nomError) && empty($prenomError) && empty($emailError) &&
- empty($listeErrorError) && empty($messageErrorError) && empty($phoneErrorError)
- )
- {
- header("Location: index.php");
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="fr">
- <head>
- <meta charset="UTF-8">
- <title>Label PHP</title>
- <meta name="">
- </head>
- <body>
- <form action="form.php" method="post">
- <p>
- <label for="nom">Nom :*</label>
- <input type="text" id="nom" name="nom">
- </p>
- <?php echo $nomError ?>
- <p>
- <label for="prenom">Prénom :*</label>
- <input type="text" id="prenom" name="prenom">
- </p>
- <?php echo $prenomError ?>
- <p>
- <label for="email">e-mail :*</label>
- <input type="text" id="email" name="email">
- </p>
- <?php echo $emailError ?>
- <p>
- <label for="phone">Enter your phone number:*</label>
-
- <input type="tel" id="phone" name="phone">
- </p>
- <?php echo $phoneError ?>
- <p>
- <label for="liste">Choose an option:*</label>
-
- <select id="liste" name="liste">
- <option value=""> Please choose an option </option>
- <option value="option1">Option 1</option>
- <option value="option2">Option 2</option>
- </select>
- </p>
- <?php echo $listeError ?>
- <p>
- <label for="message">Message :*</label>
- <textarea id="message" name="message"></textarea>
- </p>
- <?php echo $messageError ?>
- <div class="button">
- <button type="submit"name="isFormSubmitted">Envoyer votre message
- </button>
- </div>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement