Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])) {
  3.  
  4. $email_to = "contact@JTDevelopment.org";
  5. $email_subject = "Potential Web Order";
  6.  
  7. function died($error) {
  8. echo "We're sorry, but we weren't able to submit this request.";
  9. echo "The error appears to be: "."<br>";
  10. echo $error."<br /><br />";
  11. echo "Please go back and fix these errors.<br /><br />";
  12. die();
  13. }
  14.  
  15.  
  16. if(!isset($_POST['firstname']) ||
  17. !isset($_POST['lastname']) ||
  18. !isset($_POST['email']) ||
  19. !isset($_POST['company']) ||
  20. !isset($_POST['message'])
  21. !isset($_POST['budget'])) {
  22. died('We are sorry, but there appears to be a problem with the form you submitted.');
  23. }
  24.  
  25.  
  26.  
  27. $firstname = $_POST['firstname']; // required
  28. $budget = $_POST['budget']; // required
  29. $lastname = $_POST['lastname']; // required
  30. $email_from = $_POST['email']; // required
  31. $company = $_POST['company']; // required
  32. $website = $_POST['website']; // not required
  33. $comments = $_POST['message']; // required
  34.  
  35. $error_message = "Error";
  36. $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  37.  
  38. if(!preg_match($email_exp,$email_from)) {
  39. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  40. }
  41.  
  42. $string_exp = "/^[A-Za-z .'-]+$/";
  43.  
  44. if(!preg_match($string_exp,$firstname)) {
  45. $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  46. }
  47.  
  48. if(!preg_match($string_exp,$lastname)) {
  49. $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  50. }
  51.  
  52. if(strlen($comments) < 2) {
  53. $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  54. }
  55.  
  56. if(strlen($error_message) > 0) {
  57. died($error_message);
  58. }
  59.  
  60.  
  61. $email_message = "Form details below.\n\n";
  62.  
  63.  
  64. function clean_string($string) {
  65. $bad = array("content-type","bcc:","to:","cc:","href");
  66. return str_replace($bad,"",$string);
  67. }
  68.  
  69.  
  70.  
  71. $email_message .= "First Name: ".clean_string($first_name)."\n";
  72. $email_message .= "Last Name: ".clean_string($last_name)."\n";
  73. $email_message .= "Email: ".clean_string($email_from)."\n";
  74. $email_message .= "Company: ".clean_string($company)."\n";
  75. $email_message .= "Details:: ".clean_string($message)."\n";
  76. $email_message .= "Budget: ".clean_string($budget)."\n";
  77.  
  78.  
  79. $headers = 'From: '.$email_from."\r\n".
  80. 'Reply-To: '.$email_from."\r\n" .
  81. 'X-Mailer: PHP/' . phpversion();
  82. @mail($email_to, $email_subject, $email_message, $headers);
  83. ?>
  84.  
  85.  
  86. Thank you for contacting us. We will be in touch with you very soon.
  87.  
  88. <?php
  89.  
  90. }
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement