Advertisement
Guest User

Untitled

a guest
May 29th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.20 KB | None | 0 0
  1. <html dir="ltr">
  2. <head>
  3. <?php
  4. if(isset($_POST['email'])) {
  5.  
  6. // EDIT THE 2 LINES BELOW AS REQUIRED
  7. $email_to = "ferristic@gmail.com";
  8. $email_subject = "Your email subject line";
  9.  
  10.  
  11. function died($error) {
  12. // your error code can go here
  13. echo "We are very sorry, but there were error(s) found with the form your submitted. ";
  14. echo "These errors appear below.<br /><br />";
  15. echo $error."<br /><br />";
  16. echo "Please go back and fix these errors.<br /><br />";
  17. die();
  18. }
  19.  
  20. // validation expected data exists
  21. if(!isset($_POST['first_name']) ||
  22. !isset($_POST['last_name']) ||
  23. !isset($_POST['email']) ||
  24. !isset($_POST['telephone']) ||
  25. !isset($_POST['comments'])) {
  26. died('We are sorry, but there appears to be a problem with the form your submitted.');
  27. }
  28.  
  29. $first_name = $_POST['first_name']; // required
  30. $last_name = $_POST['last_name']; // required
  31. $email_from = $_POST['email']; // required
  32.  
  33. $error_message = "";
  34. $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$";
  35. if(!eregi($email_exp,$email_from)) {
  36. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  37. }
  38. $string_exp = "^[a-z .'-]+$";
  39. if(!eregi($string_exp,$first_name)) {
  40. $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  41. }
  42. if(!eregi($string_exp,$last_name)) {
  43. $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  44. }
  45. if(strlen($error_message) > 0) {
  46. died($error_message);
  47. }
  48. $email_message = "Form details below.nn";
  49.  
  50. function clean_string($string) {
  51. $bad = array("content-type","bcc:","to:","cc:","href");
  52. return str_replace($bad,"",$string);
  53. }
  54.  
  55. $email_message .= "Username: ".clean_string($first_name)."n";
  56. $email_message .= "World: ".clean_string($last_name)."n";
  57. $email_message .= "Email: ".clean_string($email_from)."n";
  58. $email_message .= "Telephone: ".clean_string($telephone)."n";
  59. $email_message .= "Comments: ".clean_string($comments)."n";
  60.  
  61.  
  62. // create email headers
  63. $headers = 'From: '.$email_from."rn".
  64. 'Reply-To: '.$email_from."rn" .
  65. 'X-Mailer: PHP/' . phpversion();
  66. @mail($email_to, $email_subject, $email_message, $headers);
  67. ?> <!-- include your own success html here -->
  68. </head>
  69. <body linkifymax="0" linkifycurrent="0" linkifying="true" spellcheck="false">
  70. <?php
  71. if(isset($_POST['email'])) {
  72.  
  73. // EDIT THE 2 LINES BELOW AS REQUIRED
  74. $email_to = "ferristic@gmail.com";
  75. $email_subject = "Your email subject line";
  76.  
  77.  
  78. function died($error) {
  79. // your error code can go here
  80. echo "We are very sorry, but there were error(s) found with the form your submitted. ";
  81. echo "These errors appear below.<br /><br />";
  82. echo $error."<br /><br />";
  83. echo "Please go back and fix these errors.<br /><br />";
  84. die();
  85. }
  86.  
  87. // validation expected data exists
  88. if(!isset($_POST['first_name']) ||
  89. !isset($_POST['last_name']) ||
  90. !isset($_POST['email']) ||
  91. !isset($_POST['telephone']) ||
  92. !isset($_POST['comments'])) {
  93. died('We are sorry, but there appears to be a problem with the form your submitted.');
  94. }
  95.  
  96. $first_name = $_POST['first_name']; // required
  97. $last_name = $_POST['last_name']; // required
  98. $email_from = $_POST['email']; // required
  99.  
  100. $error_message = "";
  101. $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$";
  102. if(!eregi($email_exp,$email_from)) {
  103. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  104. }
  105. $string_exp = "^[a-z .'-]+$";
  106. if(!eregi($string_exp,$first_name)) {
  107. $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  108. }
  109. if(!eregi($string_exp,$last_name)) {
  110. $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  111. }
  112. if(strlen($error_message) > 0) {
  113. died($error_message);
  114. }
  115. $email_message = "Form details below.nn";
  116.  
  117. function clean_string($string) {
  118. $bad = array("content-type","bcc:","to:","cc:","href");
  119. return str_replace($bad,"",$string);
  120. }
  121.  
  122. $email_message .= "Username: ".clean_string($first_name)."n";
  123. $email_message .= "World: ".clean_string($last_name)."n";
  124. $email_message .= "Email: ".clean_string($email_from)."n";
  125. $email_message .= "Telephone: ".clean_string($telephone)."n";
  126. $email_message .= "Comments: ".clean_string($comments)."n";
  127.  
  128.  
  129. // create email headers
  130. $headers = 'From: '.$email_from."rn".
  131. 'Reply-To: '.$email_from."rn" .
  132. 'X-Mailer: PHP/' . phpversion();
  133. @mail($email_to, $email_subject, $email_message, $headers);
  134. ?> <!-- include your own success html here -->
  135. <p>&nbsp;</p>
  136. <p>&nbsp;</p>
  137. <?php
  138. if(isset($_POST['email'])) {
  139.  
  140. // EDIT THE 2 LINES BELOW AS REQUIRED
  141. $email_to = "ferristic@gmail.com";
  142. $email_subject = "Your email subject line";
  143.  
  144.  
  145. function died($error) {
  146. // your error code can go here
  147. echo "We are very sorry, but there were error(s) found with the form your submitted. ";
  148. echo "These errors appear below.<br /><br />";
  149. echo $error."<br /><br />";
  150. echo "Please go back and fix these errors.<br /><br />";
  151. die();
  152. }
  153.  
  154. // validation expected data exists
  155. if(!isset($_POST['first_name']) ||
  156. !isset($_POST['last_name']) ||
  157. !isset($_POST['email']) ||
  158. !isset($_POST['telephone']) ||
  159. !isset($_POST['comments'])) {
  160. died('We are sorry, but there appears to be a problem with the form your submitted.');
  161. }
  162.  
  163. $first_name = $_POST['first_name']; // required
  164. $last_name = $_POST['last_name']; // required
  165. $email_from = $_POST['email']; // required
  166.  
  167. $error_message = "";
  168. $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$";
  169. if(!eregi($email_exp,$email_from)) {
  170. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  171. }
  172. $string_exp = "^[a-z .'-]+$";
  173. if(!eregi($string_exp,$first_name)) {
  174. $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  175. }
  176. if(!eregi($string_exp,$last_name)) {
  177. $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  178. }
  179. if(strlen($comments) < 2) {
  180. $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  181. }
  182. $string_exp = "^[0-9 .-]+$";
  183. if(!eregi($string_exp,$telephone)) {
  184. $error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
  185. }
  186. if(strlen($error_message) > 0) {
  187. died($error_message);
  188. }
  189. $email_message = "Form details below.nn";
  190.  
  191. function clean_string($string) {
  192. $bad = array("content-type","bcc:","to:","cc:","href");
  193. return str_replace($bad,"",$string);
  194. }
  195.  
  196. $email_message .= "Username: ".clean_string($first_name)."n";
  197. $email_message .= "World: ".clean_string($last_name)."n";
  198. $email_message .= "Email: ".clean_string($email_from)."n";
  199. $email_message .= "Telephone: ".clean_string($telephone)."n";
  200. $email_message .= "Comments: ".clean_string($comments)."n";
  201.  
  202.  
  203. // create email headers
  204. $headers = 'From: '.$email_from."rn".
  205. 'Reply-To: '.$email_from."rn" .
  206. 'X-Mailer: PHP/' . phpversion();
  207. @mail($email_to, $email_subject, $email_message, $headers);
  208. ?> <!-- include your own success html here -->
  209. <p>Thank you for contacting us. We will be in touch with you very soon.</p>
  210. <?
  211. }
  212. ?>
  213. </body>
  214. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement