Advertisement
Guest User

Untitled

a guest
Feb 26th, 2019
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['email'])) {
  3.  
  4. // EDIT THE 2 LINES BELOW AS REQUIRED
  5. // $email_to = "rrsd07@yahoo.com.au";
  6. $email_to = "banmeet22@gmail.com";
  7.  
  8. $email_subject = "Message From Rev Real Estate Site";
  9.  
  10. function died($error) {
  11. // your error code can go here
  12. echo "We are very sorry, but there were error(s) found with the form you submitted. ";
  13. echo "These errors appear below.<br /><br />";
  14. echo $error."<br /><br />";
  15. echo "Please go back and fix these errors.<br /><br />";
  16. die();
  17. }
  18.  
  19.  
  20. // validation expected data exists
  21. if(!isset($_POST['first_name']) ||
  22. !isset($_POST['email']) ||
  23. !isset($_POST['propertyaddress']) ||
  24. !isset($_POST['suburb']) ||
  25. !isset($_POST['postcode']) ||
  26. !isset($_POST['comments'])) {
  27. died('We are sorry, but there appears to be a problem with the form you submitted.');
  28. }
  29.  
  30.  
  31.  
  32. $first_name = $_POST['first_name']; // required
  33. $email_from = $_POST['email']; // required
  34. $propertyaddress = $_POST['propertyaddress']; // not required
  35. $suburb = $_POST['suburb']; // not required
  36. $postcode = $_POST['postcode']; // not required
  37. $comments = $_POST['comments']; // required
  38.  
  39. $error_message = "";
  40. $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/';
  41.  
  42. if(!preg_match($email_exp,$email_from)) {
  43. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  44. }
  45.  
  46. $string_exp = "/^[A-Za-z .'-]+$/";
  47.  
  48. if(!preg_match($string_exp,$first_name)) {
  49. $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  50. }
  51.  
  52.  
  53. if(strlen($comments) < 2) {
  54. $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  55. }
  56.  
  57. if(strlen($error_message) > 0) {
  58. died($error_message);
  59. }
  60.  
  61. $email_message = "Details of the Message:.nn";
  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 .= "Name: ".clean_string($first_name)."n";
  72. $email_message .= "Email: ".clean_string($email_from)."n";
  73. $email_message .= "Last Name: ".clean_string($propertyaddress)."n";
  74. $email_message .= "Suburb: ".clean_string($suburb)."n";
  75. $email_message .= "Post Code: ".clean_string($postcode)."n";
  76. $email_message .= "Comments: ".clean_string($comments)."n";
  77.  
  78. // create email headers
  79. $headers = 'From: '.$email_from."rn".
  80. 'Reply-To: '.$email_from."rn" .
  81. 'X-Mailer: PHP/' . phpversion();
  82. @mail($email_to, $email_subject, $email_message, $headers);
  83. ?>
  84.  
  85. <!-- include your own success html here -->
  86.  
  87. Thank you for contacting us. We will be in touch with you very soon.
  88.  
  89. <?php
  90.  
  91. }
  92. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement