contact.php 721 B

123456789101112131415161718192021222324
  1. <?php
  2. // Email Submit
  3. // Note: filter_var() requires PHP >= 5.2.0
  4. if ( isset($_POST['email']) && isset($_POST['name']) && isset($_POST['subject']) && isset($_POST['message']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
  5. // detect & prevent header injections
  6. $test = "/(content-type|bcc:|cc:|to:)/i";
  7. foreach ( $_POST as $key => $val ) {
  8. if ( preg_match( $test, $val ) ) {
  9. exit;
  10. }
  11. }
  12. $headers = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . '>' . "\r\n" .
  13. 'Reply-To: ' . $_POST["email"] . "\r\n" .
  14. 'X-Mailer: PHP/' . phpversion();
  15. //
  16. mail( "khaitawng2014@gmail.com", $_POST['subject'], $_POST['message'], $headers );
  17. // ^
  18. // Replace with your email
  19. }
  20. ?>