contact_me.php 1.1 KB

1234567891011121314151617181920212223242526
  1. <?php
  2. // Check for empty fields
  3. if(empty($_POST['name']) ||
  4. empty($_POST['email']) ||
  5. empty($_POST['phone']) ||
  6. empty($_POST['message']) ||
  7. !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
  8. {
  9. echo "No arguments Provided!";
  10. return false;
  11. }
  12. $name = $_POST['name'];
  13. $email_address = $_POST['email'];
  14. $phone = $_POST['phone'];
  15. $message = $_POST['message'];
  16. // Create the email and send the message
  17. $to = 'yourname@yourdomain.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
  18. $email_subject = "Website Contact Form: $name";
  19. $email_body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nPhone: $phone\n\nMessage:\n$message";
  20. $headers = "From: noreply@yourdomain.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
  21. $headers .= "Reply-To: $email_address";
  22. mail($to,$email_subject,$email_body,$headers);
  23. return true;
  24. ?>