-1

I've got a simple contact form in PHP that is to send a form input to the email address. However, the textarea isn't included. The name and e-mail is being sent, but the textarea is blank.

My form:

<form method="post" action="contact.php" id="form" role="form" class="form contact-form">                               
    <!-- Form Heading -->
    <h3 class="small-section-heading align-center">I&#39;m always open to talk</h3>

    <!-- Name -->
    <div class="form-group">
         <input type="text" name="name" id="name" class="form-control" placeholder="Name" pattern=".{2,100}" required>
    </div>

    <!-- Email -->
    <div class="form-group">
         <input type="email" name="email" id="email" class="form-control" id="" placeholder="Email" pattern=".{5,100}" required>
    </div>

    <!-- Message -->
    <div class="form-group">
         <textarea name="message" id="message" class="form-control" rows="6" placeholder="Message"></textarea>
    </div>

    <!-- Send Button -->                                 
    <button type="submit" class="btn btn-spacia btn-medium btn-full">
          Send
    </button>
</form>

My PHP Contact form:

<?php    
    $name=$_POST['name'];
    $email=$_POST['email'];
    $message=$_POST['message'];
    $from="From: $name<$email>\r\nReturn-path: $email";
    $subject="Message sent using your contact form"; 

    mail("email@example.com", $subject, $message, $from); 
?>

Thank you for contacting us. We will be in touch with you very soon. 
<?php   
     }   
?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141

1 Answers1

0

After testing your code, it seems you have a syntax error as your have a closing curly brace without an opening one. Once I removed this, it seemed to pick it up fine. So just remove the:

<?php
    }
?>

This is why it's important, in this case, to leave error_reporting on while you're developing so you have an insight into why your script isn't working.

James Nixon
  • 317
  • 4
  • 13