Guest User

Untitled

a guest
Mar 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. <?php
  2.  
  3. if ($_POST) {
  4.  
  5. $errors = array();
  6.  
  7. if (empty($_POST['nom']))
  8. {
  9. $errors['nom1'] = "Must be completed";
  10. }
  11.  
  12.  
  13. if (strlen($_POST['nom']) < 2)
  14. {
  15. $errors['nom2'] = "Your name is too short";
  16. }
  17.  
  18.  
  19.  
  20. if (empty($_POST['courriel']))
  21. {
  22. $errors['courriel1'] = "Must be completed";
  23. }
  24.  
  25.  
  26. if (strlen($_POST['courriel']) < 2)
  27. {
  28. $errors['courriel2'] = "Your mail adress is too short";
  29. }
  30.  
  31.  
  32.  
  33. if (empty($_POST['numeroTel']))
  34. {
  35. $errors['numeroTel1'] = "Must be completed";
  36. }
  37.  
  38.  
  39. if (strlen($_POST['numeroTel']) < 10)
  40. {
  41. $errors['numeroTel2'] = "Your phone number is too short";
  42. }
  43.  
  44.  
  45.  
  46.  
  47. if (empty($_POST['message']))
  48. {
  49. $errors['message1'] = "Must be completed";
  50. }
  51.  
  52. if (strlen($_POST['message']) < 2)
  53. {
  54. $errors['message2'] = "Your message is too short";
  55. }
  56.  
  57. if (count($errors)==0)
  58. {
  59. $sent = 'Message sent ! ';
  60.  
  61.  
  62. }
  63.  
  64. }
  65.  
  66. ?>
  67.  
  68.  
  69.  
  70.  
  71.  
  72. <!DOCTYPE html>
  73. <html>
  74. <head>
  75. <meta charset="utf-8">
  76. <link rel="stylesheet" type="text/css" href="style_formulaire.css">
  77. <title>Mon formulaire HTML wallah</title>
  78.  
  79. </head>
  80. <body>
  81.  
  82. <?php if(isset($sent)) echo $sent; ?>
  83. <form action="formulaire.php" method="post">
  84. <div>
  85. <label for="nom">Nom :</label>
  86. <input type="text" id="nom" name="nom" placeholder="Entrez votre nom" value="<?php if(isset($_POST['nom']) && !isset($sent)) echo $_POST['nom']; ?>" />
  87.  
  88. <p> <?php if(isset($errors['nom1'])) echo $errors['nom1']; ?></p>
  89. <p> <?php if(isset($errors['nom2'])) echo $errors['nom2']; ?></p>
  90. </div>
  91. <div>
  92. <label for="courriel">Courriel :</label>
  93. <input type="email" id="courriel" name="courriel" placeholder="Entrez votre adresse Mail" value="<?php if(isset($_POST['courriel']) && !isset($sent)) echo $_POST['courriel']; ?>" />
  94.  
  95. <p> <?php if(isset($errors['courriel1'])) echo $errors['courriel1']; ?></p>
  96.  
  97. <p> <?php if(isset($errors['courriel2'])) echo $errors['courriel2']; ?></p>
  98. </div>
  99. <div>
  100. <label for="numeroTel"> Téléphone :</label>
  101. <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']; ?>" />
  102.  
  103. <p> <?php if(isset($errors['numeroTel1'])) echo $errors['numeroTel1']; ?></p>
  104. <p> <?php if(isset($errors['numeroTel2'])) echo $errors['numeroTel2']; ?></p>
  105.  
  106. </label>
  107. </div>
  108. <div>
  109. <label for="message">Message :</label>
  110. <textarea id="message" name="message" placeholder="Ecrivez ici" ><?php if(isset($_POST['message']) && !isset($sent)) echo $_POST['message']; ?></textarea>
  111.  
  112. <p> <?php if(isset($errors['message1'])) echo $errors['message1']; ?></p>
  113. <p> <?php if(isset($errors['message2'])) echo $errors['message2']; ?></p>
  114. </div>
  115.  
  116. <div class="select">
  117. <select>
  118. <option selected>Motif du Message</option>
  119. <optgroup label="Réservation">
  120. <option>Lundi</option>
  121. <option>Mardi</option>
  122. <option>Mercredi</option>
  123. <option>Jeudi</option>
  124. <option>Vendredi</option>
  125. <option>Samedi</option>
  126. <option>Dimanche</option>
  127. </optgroup>
  128. <option> Réclamation </option>
  129. <option> Information </option>
  130. </select>
  131.  
  132. </div>
  133. <div class="button">
  134. <button type="submit">Envoyer votre message</button>
  135. </div>
  136. </form>
  137.  
  138.  
  139. </body>
  140. </html>
Add Comment
Please, Sign In to add comment