Guest User

Untitled

a guest
Jul 16th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.35 KB | None | 0 0
  1. 1. Form gets filled in
  2. 2. On click of the submit butten, javascript checks the fields.
  3. 3. If okay, javascript submits the form
  4. 4. if mail has been sent, the page is reloaded to contact.php?MailStatus=Success
  5. 5. if not (it will run a javascript giving en errormessage telling the user to retry without the fields being cleared.
  6.  
  7. <!DOCTYPE html>
  8.  
  9. <html>
  10. <head>
  11. <title>Mijn Dier En Ik</title>
  12. <meta charset="utf-8" />
  13. <meta name="viewport" content="width=device-width, initial-scale=1" />
  14. <meta name="author" content="www.csl-tech.be" />
  15. <meta name="description" content="Op zoek naar dierenhotels, artsen, winkels,... Dan is Mijn Huisdier en Ik de website die je zoekt. Neem een kijkje!" />
  16. <link rel="stylesheet" type="text/css" href="CSLCSS.css">
  17. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  18. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  19. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  20. <script src="functions.js"></script>
  21. </head>
  22.  
  23. <body>
  24.  
  25. <div class="container csl-main">
  26. <div class="row">
  27. <div class="col-md-6">
  28. <form id="MailForm" method="post">
  29. <div id="Message"></div>
  30.  
  31. <div id="FormFields">
  32. <div class="form-group">
  33. <label for="fname">Voornaam</label>
  34. <input class="form-control" type="text" id="fname" placeholder="Uw voornaam...">
  35. </div>
  36. <br />
  37. <div class="form-group">
  38. <label for="lname">Achternaam</label>
  39. <input class="form-control" type="text" id="lname" placeholder="Uw achternaam...">
  40. </div>
  41. <br />
  42. <div class="form-group">
  43. <label for="email">E-mail</label>
  44. <input class="form-control" type="text" id="email" placeholder="Uw e-mail...">
  45. </div>
  46. <br />
  47. <div class="form-group">
  48. <label for="country">Land</label>
  49. <select class="form-control" id="country" name="country">
  50. <option value="Belgie">België</option>
  51. <option value="Nederland">Nederland</option>
  52. </select>
  53. </div>
  54. <br />
  55. <div class="form-group">
  56. <label for="subject">Onderwerp</label>
  57. <select class="form-control" id="subject" name="subject">
  58. <option value="Vragen">Vragen over Mijn Dier en Ik</option>
  59. <option value="Suggesties">Suggesties voor de website</option>
  60. <option value="Reservatie of Contact">Vragen over het reservatie- en/of contactsysteem</option>
  61. <option value="Foto inzending">Foto inzenden</option>
  62. <option value="Aanpassing gegevens">Aanpassing gegevens</option>
  63. <option value="Andere">Andere</option>
  64. </select>
  65. </div>
  66. <br />
  67. <div class="form-group">
  68. <label for="message">Uw bericht</label>
  69. <textarea class="form-control" id="message" placeholder="Typ hier uw bericht..." style="height:200px"></textarea>
  70. </div>
  71. <br />
  72.  
  73. <input id="submit" class="btn btn-default" value="Versturen" onclick="CheckMailEntry()">
  74. </div>
  75. </form>
  76. </div>
  77. </div>
  78. </div>
  79.  
  80. </body>
  81.  
  82. <?php
  83. if ($_GET['MailStatus'] == 'Success') {
  84. echo '<script type="text/javascript">MailSuccess()</script>';
  85. }
  86.  
  87.  
  88. if(isset($_POST['submit'])) {
  89. header('Location: contact.php?MailStatus=Success');
  90. echo 'ok';
  91. }
  92. ?>
  93.  
  94.  
  95. </html>
  96.  
  97. function CheckMailEntry() {
  98.  
  99. document.getElementById("Message").innerHTML = "";
  100. if (document.getElementById("fname").value == "") {
  101. document.getElementById("Message").innerHTML = "<div class='alert alert-danger'><strong>Fout:</strong> Voer uw voornaam in.</div>";
  102. } else if (document.getElementById("lname").value == "") {
  103. document.getElementById("Message").innerHTML = "<div class='alert alert-danger'><strong>Fout:</strong> Voer uw achternaam in.</div>";
  104. } else if (document.getElementById("email").value == "") {
  105. document.getElementById("Message").innerHTML = "<div class='alert alert-danger'><strong>Fout:</strong> Voer uw email in.</div>";
  106. } else if (document.getElementById("message").value == "") {
  107. document.getElementById("Message").innerHTML = "<div class='alert alert-danger'><strong>Fout:</strong> Gelieve een bericht te typen.</div>";
  108. } else {
  109. document.getElementById("Message").innerHTML = "";
  110. document.getElementById("submit").submit();
  111. };
  112.  
  113. };
  114.  
  115.  
  116.  
  117. function MailSuccess() {
  118. document.getElementById("Message").innerHTML = "<div class='alert alert-success'><strong>Succes:</strong> Wij hebben uw mail ontvangen en zullen deze zo snel mogelijk beantwoorden.</div>";
  119. document.getElementById("FormFields").innerHTML = "";
  120. };
Add Comment
Please, Sign In to add comment