Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. <?php
  2. $nomError = '';
  3. $prenomError = '';
  4. $emailError = '';
  5. $phoneError = '';
  6. $listeError = '';
  7. $messageError = '';
  8.  
  9. if (isset($_POST['isFormSubmitted']))
  10. {
  11. $nom = $_POST['nom'];
  12. $prenom = $_POST['prenom'];
  13. $email = $_POST['email'];
  14. $phone = $_POST['phone'];
  15. $liste = $_POST['liste'];
  16. $message = $_POST['message'];
  17.  
  18. if (empty($nom) === true)
  19. {
  20. $nomError = '<br> Erreur : champ invalide';
  21. }
  22.  
  23. if (empty($prenom) === true)
  24. {
  25. $prenomError = '<br> Erreur : champ invalide';
  26. }
  27.  
  28. if (empty($email) === true)
  29. {
  30. $prenomError = '<br> Erreur : champ invalide';
  31. }
  32.  
  33. if (empty($phone) === true)
  34. {
  35. $phoneError = '<br> Erreur : champ invalide';
  36. }
  37.  
  38. if (empty($liste) === true)
  39. {
  40. $listeError = '<br> Erreur : champ invalide';
  41. }
  42.  
  43. if (empty($message) === true)
  44. {
  45. $messageError = '<br> Erreur : champ invalide';
  46. }
  47.  
  48. $variable = filter_var( $email,FILTER_VALIDATE_EMAIL);
  49.  
  50. if ($variable === false)
  51. {
  52. $emailError = 'Mauvais email';
  53. }
  54.  
  55. if (
  56. empty($nomError) && empty($prenomError) && empty($emailError) &&
  57. empty($listeErrorError) && empty($messageErrorError) && empty($phoneErrorError)
  58. )
  59. {
  60. header("Location: index.php");
  61. }
  62. }
  63.  
  64. ?>
  65.  
  66. <!DOCTYPE html>
  67. <html lang="fr">
  68. <head>
  69. <meta charset="UTF-8">
  70. <title>Label PHP</title>
  71. <meta name="">
  72. </head>
  73. <body>
  74. <form action="form.php" method="post">
  75. <p>
  76. <label for="nom">Nom :*</label>
  77. <input type="text" id="nom" name="nom">
  78. </p>
  79. <?php echo $nomError ?>
  80. <p>
  81. <label for="prenom">Prénom :*</label>
  82. <input type="text" id="prenom" name="prenom">
  83. </p>
  84. <?php echo $prenomError ?>
  85. <p>
  86. <label for="email">e-mail :*</label>
  87. <input type="text" id="email" name="email">
  88. </p>
  89. <?php echo $emailError ?>
  90. <p>
  91. <label for="phone">Enter your phone number:*</label>
  92. <input type="tel" id="phone" name="phone">
  93. </p>
  94. <?php echo $phoneError ?>
  95. <p>
  96. <label for="liste">Choose an option:*</label>
  97. <select id="liste" name="liste">
  98. <option value=""> Please choose an option </option>
  99. <option value="option1">Option 1</option>
  100. <option value="option2">Option 2</option>
  101. </select>
  102. </p>
  103. <?php echo $listeError ?>
  104. <p>
  105. <label for="message">Message :*</label>
  106. <textarea id="message" name="message"></textarea>
  107. </p>
  108. <?php echo $messageError ?>
  109. <div class="button">
  110. <button type="submit"name="isFormSubmitted">Envoyer votre message
  111. </button>
  112. </div>
  113. </form>
  114. </body>
  115. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement