Guest User

Untitled

a guest
May 21st, 2018
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.36 KB | None | 0 0
  1. <?php
  2.  
  3. if (isset($_POST['email'])) {
  4.  
  5.     // CHANGE THE TWO LINES BELOW
  6.     $email_to = "jordan_gunz@hotmail.com";
  7.  
  8.     $email_subject = "portfolio contact";
  9.  
  10.     function checkEmail($email)
  11.     {
  12.         if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])
  13.  ↪*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email)) {
  14.             list($username, $domain) = split('@', $email);
  15.             if (!checkdnsrr($domain, 'MX')) {
  16.                 return false;
  17.             }
  18.             return true;
  19.         }
  20.         return false;
  21.     }
  22.  
  23.     function died($error)
  24.     {
  25.         // your error code can go here
  26.         echo "We're sorry, but there's errors found with the form you submitted.<br /><br />";
  27.         echo $error . "<br /><br />";
  28.         echo "Please go back and fix these errors.<br /><br />";
  29.         die();
  30.     }
  31.  
  32.     // validation expected data exists
  33.     if (!isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['comments'])) {
  34.         died('We are sorry, but there appears to be a problem with the form you submitted.');
  35.     }
  36.  
  37.     $last_name = $_POST['last_name']; // required
  38.     $email_from = $_POST['email']; // required
  39.     $comments = $_POST['comments']; // required
  40.  
  41.     $error_message = "";
  42.     if (checkEmail($email_from)) {
  43.         $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  44.     }
  45.     if (strlen($comments) < 2) {
  46.         $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  47.     }
  48.     if (strlen($error_message) > 0) {
  49.         died($error_message);
  50.     }
  51.     $email_message = "Form details below.\n\n";
  52.  
  53.     function clean_string($string)
  54.     {
  55.         $bad = array("content-type", "bcc:", "to:", "cc:", "href");
  56.         return str_replace($bad, "", $string);
  57.     }
  58.  
  59.     $email_message .= "Last Name: " . clean_string($last_name) . "\n";
  60.     $email_message .= "Email: " . clean_string($email_from) . "\n";
  61.     $email_message .= "Comments: " . clean_string($comments) . "\n";
  62.  
  63.     // create email headers
  64.     $headers = 'From: ' . $email_from . "\r\n" . 'Reply-To: ' . $email_from . "\r\n" .
  65.         'X-Mailer: PHP/' . phpversion();
  66.     @mail($email_to, $email_subject, $email_message, $headers);
  67. ?>
  68.  
  69. <!-- place your own success html below -->
  70.  
  71. Bedankt voor uw bericht er wordt zo snel mogelijk contact me u opgenomen..
  72.  
  73. <?php
  74. }
  75. die();
  76. ?>
Add Comment
Please, Sign In to add comment