Public paste
script
By: geeMc | Date: Jan 31 2007 21:13 | Format: PHP | Expires: never | Size: 3.38 KB | Hits: 1459

  1. <?
  2. // geef e-mail adres op van ontvanger
  3. $mail_ontv = "biggie@biggie.nl";
  4.  
  5. // is niet 100% !!!
  6. function checkmail($mail)
  7. {
  8. $email_host = explode("@", $mail);
  9. $email_host = $email_host['1'];
  10. $email_resolved = gethostbyname($email_host);
  11.  
  12. if ($email_resolved != $email_host && eregi("^[0-9a-z]([-_.~]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,4}$",$mail))
  13. $valid = 1;
  14.  
  15. return $valid;
  16. }
  17.  
  18. // als er niet op submit is gedrukt, of als er wel op is gedrukt maar niet alles ingevoerd is
  19. if (!$_POST['submit'] || $_POST['submit'] && (!$_POST['naam'] || !$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs'] || !$_POST['onderwerp']))
  20. {
  21. if ($_POST['submit'] && (!$_POST['naam'] || !$_POST['mail'] || !checkmail($_POST['mail']) || !$_POST['msggs'] || !$_POST['onderwerp']))
  22. {
  23. echo "U heeft iets niet ingevuld, ";
  24. echo "of u heeft iets verkeerd ingevuld.<p>";
  25. }
  26.  
  27. // form + tabel
  28. echo "<table border="0" cellspacing="0" cellpadding="0">";
  29. echo "<form method="POST" ACTION="" . $_SERVER['PHP_SELF'] . "">";
  30.  
  31. // naam
  32. echo "<tr><td>Naam:</td></tr>";
  33. echo "<tr><td><input type="text" name="naam" value="" . $_POST['naam'] . ""></td></tr>";
  34.  
  35. // mail
  36. echo "<tr><td>Je E-Mail adres:</td></tr>";
  37. echo "<tr><td><input type="text" name="mail" value="" . $_POST['mail'] . ""></td></tr>";
  38.  
  39. // mail
  40. echo "<tr><td>Onderwerp:</td></tr>";
  41. echo "<tr><td><input type="text" name="onderwerp" value="" . $_POST['onderwerp'] . ""></td></tr>";
  42.  
  43. // mail
  44. echo "<tr><td>Tekst:</td></tr>";
  45. echo "<tr><td><TEXTAREA name="msggs" ROWS="4" COLS="45">" . htmlentities($_POST['msggs']) . "</TEXTAREA></td></tr>";
  46.  
  47. // button
  48. echo "<tr><td>&nbsp;</td></tr>";
  49. echo "<tr><td><input type="submit" name="submit" value="Vroag ut!!"></td></tr>";
  50.  
  51. // sluit form + tabel
  52. echo "</form>";
  53. echo "</table>";
  54. }
  55. // versturen naar
  56. else
  57. {
  58. // set datum
  59. $datum = date("d.m.Y H:i");
  60.  
  61. // set ip
  62. $ip = $_SERVER['REMOTE_ADDR'];
  63.  
  64. $inhoud_mail = "===================================================n";
  65. $inhoud_mail .= "Ingevulde contact formuliern";
  66. $inhoud_mail .= "===================================================nn";
  67.  
  68. $inhoud_mail .= "Naam: " . $_POST['naam'] . "n";
  69. $inhoud_mail .= "E-mail adres: " . $_POST['mail'] . "n";
  70. $inhoud_mail .= "Bericht:n";
  71. $inhoud_mail .= $_POST['msggs'] . "nn";
  72.  
  73. $inhoud_mail .= "Verstuurd op $datum via het ip " . $ip . "nn";
  74.  
  75. $inhoud_mail .= "===================================================nn";
  76.  
  77. // --------------------
  78. // spambot protectie
  79.  
  80. $headers = "From: " . $_POST['naam'] . " <" . $_POST['mail'] . ">";
  81.  
  82. $headers = stripslashes($headers);
  83. $headers = str_replace("n", "", $headers); // Verwijder n
  84. $headers = str_replace("r", "", $headers); // Verwijder r
  85. $headers = str_replace(""", "\"", str_replace("\", "\\", $headers)); // Slashes van quotes
  86.  
  87. $_POST['onderwerp'] = str_replace("n", "", $_POST['onderwerp']); // Verwijder n
  88. $_POST['onderwerp'] = str_replace("r", "", $_POST['onderwerp']); // Verwijder r
  89. $_POST['onderwerp'] = str_replace(""", "\"", str_replace("\", "\\", $_POST['onderwerp'])); // Slashes van quotes
  90.  
  91. mail($mail_ontv, $_POST['onderwerp'], $inhoud_mail, $headers);
  92.  
  93. echo "<h1>Uw E-Mail is verstuurd.</h1>";
  94.  
  95. echo "<p>Bedankt voor je mail. Wij zullen ";
  96. echo "je zo snel mogelijk beantwoorden.</p>";  
  97. }
  98. ?>