contact.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. // Email address verification
  3. function isEmail($email) {
  4. return filter_var($email, FILTER_VALIDATE_EMAIL);
  5. }
  6. if($_POST) {
  7. // Enter the email where you want to receive the message
  8. $emailTo = 'madame.d.jour@gmail.com';
  9. $clientEmail = addslashes(trim($_POST['email']));
  10. $subject = addslashes(trim($_POST['subject']));
  11. $message = addslashes(trim($_POST['message']));
  12. $array = array('emailMessage' => '', 'subjectMessage' => '', 'messageMessage' => '');
  13. if(!isEmail($clientEmail)) {
  14. $array['emailMessage'] = 'Invalid email!';
  15. }
  16. if($subject == '') {
  17. $array['subjectMessage'] = 'Empty subject!';
  18. }
  19. if($message == '') {
  20. $array['messageMessage'] = 'Empty message!';
  21. }
  22. if(isEmail($clientEmail) && $subject != '' && $message != '') {
  23. // Send email
  24. $headers = "From: " . $clientEmail . " <" . $clientEmail . ">" . "\r\n" . "Reply-To: " . $clientEmail;
  25. mail($emailTo, $subject . " (bootstrap contact form)", $message, $headers);
  26. }
  27. // The echo command just outputs text. So all this line is doing is displaying whatever is in the
  28. // array variable on the page.
  29. //echo json_encode($array);
  30. // This line basically uses javascript to throw up an alert confirming success & then redirects the user to
  31. // the main page of the site once they confirm the alert. You may need to change the URL if you move the files
  32. // out of the revamp folder (just remove the "revamp" from the URL.
  33. echo '<script type="text/javascript">alert("Thanks for contacting me."); window.location.href="LINK"; </script>';
  34. }
  35. ?>