Guest User

Untitled

a guest
Jan 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. <form action="" method="POST">
  2. <ul class="form-style-1">
  3. <li>
  4. <input type="text" id="mail-name" name="name" class="field-divided" maxlength="15" placeholder="Voornaam *" />&nbsp;<input type="text" id="mail-lastname" name="lastname" class="field-divided" maxlength="15" placeholder="Achternaam" >
  5. </li>
  6. <li>
  7. <input type="text" id="mail-email" name="email" placeholder="E-mail *" class="field-long" maxlength="40" >
  8. </li>
  9. <li>
  10. <input type ="text" id="mail-phone" name="phone" placeholder="Telefoonnummer" class="field-long" maxlength = "15">
  11. </li>
  12. <button class="mail-submit" id="mail-submit" type="submit" name="submit">Versturen</button>
  13. <span style="color: #0184b2; text-align: center; font-size: 20px; margin: 0 auto; display: block; padding-top: 10px;" class="form-message"></span>
  14. </ul>
  15. </form>
  16.  
  17. $("form").on("submit",function(event){
  18. event.preventDefault();
  19. var name = $("#mail-name").val();
  20. var lastname = $("#mail-lastname").val();
  21. var email = $("#mail-email").val();
  22. var phone = $("#mail-phone").val();
  23. var subject = $("#mail-subject").val();
  24. var information = $("#mail-information").val();
  25. $.post("donation-contact.php",
  26. {
  27. name: name,
  28. lastname: lastname,
  29. email: email,
  30. phone: phone,
  31. submit: "yes"
  32. },
  33. function(data){
  34. $(".form-message").html( data );
  35. }
  36. );
  37. });
  38.  
  39. <?php
  40.  
  41. if (isset($_POST['submit'])) {
  42.  
  43.  
  44. $email_to = "#";
  45.  
  46. $email_subject = "#";
  47.  
  48. $name = $_POST['name'];
  49. $lastname = $_POST['lastname'];
  50. $email = $_POST['email'];
  51. $phone = $_POST['phone'];
  52.  
  53.  
  54. $errorEmpty = false;
  55. $errorEmail = false;
  56.  
  57. if (empty($name)) {
  58. echo "<span class='form-error'>Voer de verplichte velden in!</span>";
  59. $errorEmpty = true;
  60. }
  61. elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  62. echo "<span class='form-error'>Geef een geldig E-mail!</span>";
  63. $errorEmail = true;
  64. }
  65. else {
  66. $formcontent=" Naam: $name nn Achternaam: $lastname nn Email: $email nn Telefoon: $phone";
  67. $mailheader = "From: ".$_POST["email"]."rn";
  68. $headers = "From: ". htmlspecialchars($_POST['name']) ." <" . $_POST['email'] . ">rn";
  69. $headers .= "Reply-To: " . $_POST['email'] . "rn";
  70. $headers .= "MIME-Version: 1.0rn";
  71. $headers .= "Content-Type: text/html; charset=ISO-8859-1rn";
  72. mail($email_to, $email_subject, $formcontent, $mailheader);
  73. echo "<span class='form-success'>De mail is verzonden!</span>";
  74. }
  75.  
  76. }
  77.  
  78.  
  79. ?>
Add Comment
Please, Sign In to add comment