Advertisement
Tomchepom

Untitled

Sep 16th, 2014
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. <?php
  2.  
  3. if(!$_POST) exit;
  4.  
  5. // Email address verification, do not edit.
  6. function isEmail($email) {
  7. return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));
  8. }
  9.  
  10. if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");
  11.  
  12. $name = $_POST['name'];
  13. $email = $_POST['email'];
  14. $comment = $_POST['comment'];
  15. //$verify = $_POST['verify'];
  16.  
  17. if(trim($name) == '') {
  18. echo '<div class="error_message">Attention! You must enter your name.</div>';
  19. exit();
  20. } else if(trim($email) == '') {
  21. echo '<div class="error_message">Attention! Please enter a valid email address.</div>';
  22. exit();
  23. } else if(trim($comment) == '') {
  24. echo '<div class="error_message">Attention! Please enter a message.</div>';
  25. exit();
  26. } else if(!isEmail($email)) {
  27. echo '<div class="error_message">Attention! You have enter an invalid e-mail address, try again.</div>';
  28. exit();
  29. }
  30.  
  31. /*
  32. if(trim($subject) == '') {
  33. echo '<div class="error_message">Attention! Please enter a subject.</div>';
  34. exit();
  35. } else if(trim($comments) == '') {
  36. echo '<div class="error_message">Attention! Please enter your message.</div>';
  37. exit();
  38. } else if(!isset($verify) || trim($verify) == '') {
  39. echo '<div class="error_message">Attention! Please enter the verification number.</div>';
  40. exit();
  41. } else if(trim($verify) != '4') {
  42. echo '<div class="error_message">Attention! The verification number you entered is incorrect.</div>';
  43. exit();
  44. }
  45. */
  46.  
  47. if(get_magic_quotes_gpc()) {
  48. $comments = stripslashes($comments);
  49. }
  50.  
  51.  
  52. // Configuration option.
  53. // Enter the email address that you want to emails to be sent to.
  54. // Example $address = "joe.doe@yourdomain.com";
  55.  
  56. $address = "support@[removed]";
  57.  
  58.  
  59. // Configuration option.
  60. // i.e. The standard subject will appear as, "You've been contacted by John Doe."
  61.  
  62. // Example, $e_subject = '$name . ' has contacted you via Your Website.';
  63.  
  64. $e_subject = 'Email from: ' . $name . '.';
  65.  
  66.  
  67. // Configuration option.
  68. // You can change this if you feel that you need to.
  69. // Developers, you may wish to add more fields to the form, in which case you must be sure to add them here.
  70.  
  71. $e_body = "You have been contacted by $name with regards to $subject, their additional message is as follows." . PHP_EOL . PHP_EOL;
  72. $e_content = "\"$comments\"" . PHP_EOL . PHP_EOL;
  73. $e_reply = "You can contact $name via email, $email or via phone $phone";
  74.  
  75. $msg = wordwrap( $e_body . $e_content . $e_reply, 70 );
  76.  
  77. $headers = "From: $email" . PHP_EOL;
  78. $headers .= "Reply-To: $email" . PHP_EOL;
  79. $headers .= "MIME-Version: 1.0" . PHP_EOL;
  80. $headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
  81. $headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;
  82.  
  83. if(mail($address, $e_subject, $msg, $headers)) {
  84.  
  85. // Email has sent successfully, echo a success page.
  86.  
  87. echo "<fieldset>";
  88. echo "<div id='success_page'>";
  89. echo "<strong class=\"success\">Email Sent Successfully.</strong>";
  90. echo "<p>Thank you <strong>$name</strong>, please allow up to 5 business days for a response.</p>";
  91. echo "</div>";
  92. echo "</fieldset>";
  93.  
  94. } else {
  95.  
  96. echo 'ERROR!';
  97.  
  98. }
  99.  
  100. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  101.  
  102. Placed on my page -
  103.  
  104. <h3>CONTACT US</h3>
  105. </div>
  106.  
  107. <form action="ajax-contact-form/contact.php" class="form-inline" name="contactform" id="contactform" role="form">
  108. <div class="form-group">
  109. <div class="col-sm-6">
  110. <label class="sr-only" for="name">Name</label>
  111. <input type="text" class="fixed form-control" id="name" placeholder="Your name">
  112. </div>
  113. <div class="col-sm-6">
  114. <label class="sr-only" for="email">Email</label>
  115. <input size="25" type="email" class="fixed form-control" id="email" placeholder="Enter email">
  116. </div>
  117. </div>
  118. <div class="form-group">
  119. <label class="sr-only" for="comment">Message</label>
  120. <textarea class="form-control" id="comment" rows="5" placeholder="Message..."></textarea>
  121. </div>
  122. <div class="form-group resp-center">
  123. <button type="submit" class="btn btn-primary btn-md">SEND MESSAGE</button>
  124. </div>
  125. </form>
  126. <div id="message"></div>
  127.  
  128. </div>
  129. </div>`enter code here`
  130. </div>
  131. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement