Advertisement
esepich

Untitled

Mar 15th, 2015
448
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. $to = "destination@mail.com";
  5. $copy = "mymail@mail.com";
  6. $subject = "Email..";
  7. if (isset($_POST["contactSubscribe"]) || isset($_POST["questionSubmit"]) || isset($_POST["submit"])) {
  8. foreach ($_POST as $field => $value) {
  9. if ($field == "contactName") {
  10. $contactName = $value;
  11. }
  12. if ($field == "email") {
  13. $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
  14. }
  15. if ($field == "comment") {
  16. $comment = $value;
  17. }
  18. }
  19. }
  20.  
  21. checkConditions();
  22. mail($to, $subject, $message);
  23. mail($copy, $subject, $message);
  24. }
  25.  
  26. function checkConditions()
  27. {
  28. if ( condition1() ) $message = "Name: $contactName Email: $email";
  29. if ( condition2() ) && is_null($contactName)) $message = "inputname=i_" . $email;
  30. if ( condition3() ) && !is_null($comment) ) $message = "Name: $contactName Email: $email Message: $comment";
  31. }
  32.  
  33. function condition1()
  34. {
  35. return !is_null($contactName) && is_null($comment);
  36. }
  37.  
  38. function condition2()
  39. {
  40. return is_null($comment) && is_null($contactName);
  41. }
  42.  
  43. function condition3()
  44. {
  45. return !is_null($contactName) && !is_null($comment);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement