Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ($_POST) {
- $errors = array();
- if (empty($_POST['nom']))
- {
- $errors['nom1'] = "Must be completed";
- }
- if (strlen($_POST['nom']) < 2)
- {
- $errors['nom2'] = "Your name is too short";
- }
- if (empty($_POST['courriel']))
- {
- $errors['courriel1'] = "Must be completed";
- }
- if (strlen($_POST['courriel']) < 2)
- {
- $errors['courriel2'] = "Your mail adress is too short";
- }
- if (empty($_POST['numeroTel']))
- {
- $errors['numeroTel1'] = "Must be completed";
- }
- if (strlen($_POST['numeroTel']) < 10)
- {
- $errors['numeroTel2'] = "Your phone number is too short";
- }
- if (empty($_POST['message']))
- {
- $errors['message1'] = "Must be completed";
- }
- if (strlen($_POST['message']) < 2)
- {
- $errors['message2'] = "Your message is too short";
- }
- if (count($errors)==0)
- {
- $sent = 'Message sent ! ';
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <link rel="stylesheet" type="text/css" href="style_formulaire.css">
- <title>Mon formulaire HTML wallah</title>
- </head>
- <body>
- <?php if(isset($sent)) echo $sent; ?>
- <form action="formulaire.php" method="post">
- <div>
- <label for="nom">Nom :</label>
- <input type="text" id="nom" name="nom" placeholder="Entrez votre nom" value="<?php if(isset($_POST['nom']) && !isset($sent)) echo $_POST['nom']; ?>" />
- <p> <?php if(isset($errors['nom1'])) echo $errors['nom1']; ?></p>
- <p> <?php if(isset($errors['nom2'])) echo $errors['nom2']; ?></p>
- </div>
- <div>
- <label for="courriel">Courriel :</label>
- <input type="email" id="courriel" name="courriel" placeholder="Entrez votre adresse Mail" value="<?php if(isset($_POST['courriel']) && !isset($sent)) echo $_POST['courriel']; ?>" />
- <p> <?php if(isset($errors['courriel1'])) echo $errors['courriel1']; ?></p>
- <p> <?php if(isset($errors['courriel2'])) echo $errors['courriel2']; ?></p>
- </div>
- <div>
- <label for="numeroTel"> Téléphone :</label>
- <input id="telNo" type="tel" pattern="^(?:0|\(?\+33\)?\s?|0033\s?)[1-79](?:[\.\-\s]?\d\d){4}$" name="numeroTel" placeholder="Entrez votre numéro de téléphone" value="<?php if(isset($_POST['numeroTel']) && !isset($sent)) echo $_POST['numeroTel']; ?>" />
- <p> <?php if(isset($errors['numeroTel1'])) echo $errors['numeroTel1']; ?></p>
- <p> <?php if(isset($errors['numeroTel2'])) echo $errors['numeroTel2']; ?></p>
- </label>
- </div>
- <div>
- <label for="message">Message :</label>
- <textarea id="message" name="message" placeholder="Ecrivez ici" ><?php if(isset($_POST['message']) && !isset($sent)) echo $_POST['message']; ?></textarea>
- <p> <?php if(isset($errors['message1'])) echo $errors['message1']; ?></p>
- <p> <?php if(isset($errors['message2'])) echo $errors['message2']; ?></p>
- </div>
- <div class="select">
- <select>
- <option selected>Motif du Message</option>
- <optgroup label="Réservation">
- <option>Lundi</option>
- <option>Mardi</option>
- <option>Mercredi</option>
- <option>Jeudi</option>
- <option>Vendredi</option>
- <option>Samedi</option>
- <option>Dimanche</option>
- </optgroup>
- <option> Réclamation </option>
- <option> Information </option>
- </select>
- </div>
- <div class="button">
- <button type="submit">Envoyer votre message</button>
- </div>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment