0

I am trying to get my HTML form to send me an email with the data that the user entered into the form. my HTML:

 <form method="post" action="php/contact.php" id="contact_form">
          <div class="row">
              <div class="large-6 columns">
                <label for="contact_name">Your Name<em>*</em></label>
                <input type="text" placeholder="e.g. John Doe" id="contact_name" name="contact_name" class="required form-control">
              </div>
              <div class="large-6 columns contactEmail">
                <label for="contact_email">Your Email<em>*</em></label>
                <input type="email" placeholder="e.g. John@Doe.com" id="contact_email" name="contact_email" class="required email form-control">
              </div>
          </div>
          <div class="row">
          </div>
          <div class="row">
            <div class="large-12 columns">
              <label for="contact_message">Your Message<em>*</em></label>
              <textarea placeholder="e.g. Let's work together!" id="contact_message" name="contact_message" class="required form-control"></textarea>
            </div>
          </div>
          <div class="row">
            <div class="large-12 columns">
              <input type="submit" name="contact_submit" id="contact_submit" value="SEND MESSAGE" class="button" style="color: black;">
            </div>
          </div>
        </form>

Below is my PHP. Any insight to how I can get this working would be great! Thank you.

    <?php 
if(isset($_POST['submit'])){
    $to = "ccounard95@gmail.com"; // this is your Email address
    $from = $_POST['contact_email']; // this is the sender's Email address
    $first_name = $_POST['contact_name'];
    $subject = "Form submission";
    $subject2 = "Copy of your form submission";
    $message = $contact_name . " " . " wrote the following:" . "\n\n" . $_POST['message'];
    $message2 = "Here is a copy of your message " . $contact_name . "\n\n" . $_POST['message'];

    $headers = "From:" . $from;
    $headers2 = "From:" . $to;
    mail($to,$subject,$message,$headers);
    mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
    echo "Mail Sent. Thank you " . $contact_name . ", we will contact you shortly.";
    }
?>
John Wick
  • 1
  • 1

0 Answers0