Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. <?php
  2.  
  3. var_dump($_POST);
  4.  
  5. if($_POST)
  6. {
  7.  
  8. $error = array();
  9.  
  10.  
  11.  
  12.  
  13. if (empty($_POST['name']))
  14. {
  15. echo $error['name'] = "Your name can't be empty";
  16. }
  17.  
  18. if (empty($_POST['lastname']))
  19. {
  20. $error['lastname'] = "Your last name can't be empty";
  21. }
  22.  
  23.  
  24. if (empty($_POST['phone']))
  25. {
  26. $error['phone'] = "Your phone number can't be empty";
  27. }
  28.  
  29. if (empty($_POST['subjet']))
  30. {
  31. $error['subjet'] = "The subjet can't be empty";
  32. }
  33.  
  34. if (!filter_var($_POST['email']))
  35. {
  36. $error['email'] = "The mail can't be empty";
  37. }
  38.  
  39. if (empty($_POST['msg']))
  40. {
  41. $error['msg'] = "The Message can't be empty";
  42. }
  43.  
  44.  
  45.  
  46.  
  47. if (count($error) == 0)
  48. {
  49. //redirection
  50. header("Location: sucess.php");
  51. exit();
  52. }
  53.  
  54. }
  55.  
  56. ?>
  57.  
  58.  
  59. <!DOCTYPE html>
  60. <html lang="fr">
  61. <head>
  62. <meta charset="utf-8" />
  63. <title>test</title>
  64. </head>
  65. <body>
  66.  
  67.  
  68. <fieldset>
  69. <form action="sucess.php" method="get">
  70.  
  71.  
  72. <div>
  73. <label for="name">Name :</label>
  74. <input type="text" id="name" name="name" placeholder="exp:Max" required>
  75. <p><?php if (isset($error['name'])) echo $error['name']; ?></p>
  76. </div>
  77.  
  78.  
  79. <hr>
  80. <div>
  81. <label for="lastname">Last name :</label>
  82. <input type="text" id="lastname" name="lastname" placeholder="exp:Tony" required>
  83. <p><?php if (isset($error['lastname'])) echo $error['lastname']; ?></p>
  84. </div>
  85.  
  86. <hr>
  87.  
  88. <div>
  89. <label for="phone">Phone number :</label>
  90. <input type="tel" id="phone" name="phone" placeholder="exp:06 99 99 99 99" required>
  91. <p><?php if (isset($error['phone'])) echo $error['phone']; ?></p>
  92. </div>
  93.  
  94. <hr>
  95.  
  96. <div>
  97. <label for="subjet">What you need to know</label>
  98. <select name="subjet" id="subjet" required>
  99. <option value="aaaaa">aaaaa</option>
  100. <option value="bbbbb">bbbbb</option>
  101. <option value="ccccc">ccccc</option>
  102. <option value="ddddd">ddddd</option>
  103. </select>
  104. <p><?php if (isset($error['subjet'])) echo $error['subjet'];?></p>
  105. </div>
  106.  
  107. <div>
  108. <label for ="email">E-mail :</label>
  109. <input type="email" name="email "id="email" placeholder="exp:MaxTony@ddd.com">
  110. <p><?php if (isset($error['email'])) echo $error['email'];?></p>
  111. </div>
  112. <hr>
  113. <div>
  114. <label for="msg">Message :</label>
  115. <textarea id="msg" name="msg" placeholder="exp:izeji iejioj ijaei." required></textarea>
  116. <p><?php if (isset($error['msg'])) echo $error['msg'];?></p>
  117. </div>
  118.  
  119. <input type="submit" name="submit">
  120. </form>
  121.  
  122. </fieldset>
  123.  
  124.  
  125.  
  126. </body>
  127. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement