esepich

Untitled

Mar 15th, 2015
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. function sendMail()
  2. {
  3. $comment = null;
  4. $copy = "[email protected]";
  5. $subject = "Email..";
  6. if (isset($_POST["contactSubscribe"]) || isset($_POST["questionSubmit"]) || isset($_POST["submit"])) {
  7. foreach ($_POST as $field => $value) {
  8. if ($field == "contactName") {
  9. $contactName = $value;
  10. }
  11. if ($field == "email") {
  12. $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
  13. }
  14. if ($field == "comment") {
  15. $comment = $value;
  16. }
  17. }
  18. }
  19.  
  20. checkConditions();
  21. mail($to, $subject, $message);
  22. mail($copy, $subject, $message);
  23. }
  24.  
  25. function checkConditions()
  26. {
  27. if ( condition1() ) $message = "Name: $contactName Email: $email";
  28. if ( condition2() ) && is_null($contactName)) $message = "inputname=i_" . $email;
  29. if ( condition3() ) && !is_null($comment) ) $message = "Name: $contactName Email: $email Message: $comment";
  30. }
  31.  
  32. function condition1()
  33. {
  34. return !is_null($contactName) && is_null($comment);
  35. }
  36.  
  37. function condition2()
  38. {
  39. return is_null($comment) && is_null($contactName);
  40. }
  41.  
  42. function condition3()
  43. {
  44. return !is_null($contactName) && !is_null($comment);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment