Guest User

Untitled

a guest
Jul 17th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. if($_SERVER['REQUEST_METHOD'] == "POST" && $_POST['contact'] == "Versturen")
  4. {
  5. $required = array("Naam", "E-mailadres");
  6. $valid = true;
  7.  
  8. $html = '<style type="text/css"> body { font-family: Arial; font-size: 12px; } td { padding: 5px; border-bottom: 1px solid #F1F1F1} </style>';
  9. $html .= '<table width="100%" border="0" cellspacing="1" cellpadding="2">';
  10.  
  11. $msg = array();
  12. foreach ($_POST as $key => $value)
  13. {
  14. if(in_array($key, $required) && (str_replace(" ", "", $value) == "" || $key == $value)){
  15. $valid = false;
  16. $msg[] = '<strong>' . $key . '</strong> is een verplicht veld';
  17. }
  18. if($key != "submit" && $key != "aanmeld-id")
  19. {
  20.  
  21. $html .= '<tr>';
  22.  
  23. $html .= '<td width="100px">' . ucfirst($key) . " : </td> <td>" . htmlspecialchars(trim($value)) . "</td>";
  24.  
  25. $html .= '</tr>';
  26.  
  27. }
  28. }
  29.  
  30.  
  31. $html .= '</table>';
  32.  
  33. if(!preg_match("/[A-Za-z0-9_-]+([\.]{1}[A-Za-z0-9_-]+)*@[A-Za-z0-9-]+([\.]{1}[A-Za-z0-9-]+)+/",$_POST['E-mailadres'])){
  34. $valid = false;
  35. $msg[] = 'Dit is geen geldig e-mailadres';
  36. }
  37.  
  38. if($valid)
  39. {
  40. $to = 'kelvin@bekent.nl';
  41. $subject = 'CONTACTFORMULIER VANAF BAAAKJE.nl';
  42.  
  43. $headers = 'MIME-Version: 1.0' . "\r\n";
  44. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  45. $headers .= 'From: $to' . "\r\n" .
  46. 'Reply-To: $to' . "\r\n" .
  47. 'X-Mailer: PHP/' . phpversion();
  48.  
  49. if(mail($to, $subject, $html, $headers)){
  50. $html = "<div class='succes'>Uw gegevens zijn succesvol verstuurd. We nemen zo spoedig mogelijk contact met u op</div>";
  51. }
  52. else{
  53. $html = "<div class='error'>Er is een onbekende fout opgetreden</div>";
  54. }
  55.  
  56. }
  57. else
  58. {
  59. $html = "<div class='error'><ul>";
  60. foreach($msg as $item){
  61. $html .= "<li>$item</li>";
  62. }
  63. $html .= "</ul></div>";
  64. }
  65. echo $html;
  66. }
  67. ?>
  68. <form method='post' action=''>
  69. <table>
  70. <tr>
  71. <td style='padding-right: 20px'>
  72. <label for='naam'>Naam:</label>
  73. <input size='38' type='text' name='Naam' value='' />
  74. <label for='Email'>E-mailadres:</label>
  75. <input size='38' type='text' name='E-mailadres' value='' />
  76. <label for='Telefoon'>Telefoonnummer:</label>
  77. <input size='20' maxlength='15' type='text' name='Telefoon' value='' />
  78. </td>
  79. </tr>
  80. <tr>
  81. <td>
  82. <input type='submit' class='submit' name="contact" value='Versturen' />
  83. </td>
  84. </tr>
  85. </table>
  86. </form>
Add Comment
Please, Sign In to add comment