Guest User

Untitled

a guest
Aug 19th, 2019
235
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. if(isset($_POST['email'])) {
  3.  
  4. // EDIT THE 2 LINES BELOW AS REQUIRED
  5. $email_to = "you@yourdomain.com";
  6. $email_subject = "Your email subject line";
  7.  
  8. function died($error) {
  9. // your error code can go here
  10. echo "We are very sorry, but there were error(s) found with the form you submitted. ";
  11. echo "These errors appear below.<br /><br />";
  12. echo $error."<br /><br />";
  13. echo "Please go back and fix these errors.<br /><br />";
  14. die();
  15. }
  16.  
  17.  
  18. // validation expected data exists
  19. if(!isset($_POST['date']) ||
  20. !isset($_POST['time']) ||
  21. !isset($_POST['email'])) {
  22. died('We are sorry, but there appears to be a problem with the form you submitted.');
  23. }
  24.  
  25.  
  26.  
  27. $first_name = $_POST['date']; // required
  28. $last_name = $_POST['time']; // required
  29. $email_from = $_POST['email']; // required
  30.  
  31.  
  32.  
  33. $error_message = "";
  34. $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  35.  
  36. if(!preg_match($email_exp,$email_from)) {
  37. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  38. }
  39.  
  40. $string_exp = "/^[A-Za-z .'-]+$/";
  41.  
  42. if(strlen($error_message) > 0) {
  43. died($error_message);
  44. }
  45.  
  46. $email_message = "Form details below.\n\n";
  47.  
  48.  
  49. function clean_string($string) {
  50. $bad = array("content-type","bcc:","to:","cc:","href");
  51. return str_replace($bad,"",$string);
  52. }
  53.  
  54.  
  55.  
  56. $email_message .= "Date: ".clean_string($date)."\n";
  57. $email_message .= "Time: ".clean_string($time)."\n";
  58. $email_message .= "Email: ".clean_string($email)."\n";
  59.  
  60. // create email headers
  61. $headers = 'From: '.$email_from."\r\n".
  62. 'Reply-To: '.$email_from."\r\n" .
  63. 'X-Mailer: PHP/' . phpversion();
  64. @mail($email_to, $email_subject, $email_message, $headers);
  65. ?>
  66.  
  67. <!-- include your own success html here -->
  68.  
  69. Thank you for contacting us. We will be in touch with you very soon.
  70.  
  71. <?php
  72.  
  73. }
  74. ?>
RAW Paste Data