title: PHP form submit
body: <p>I have a problem with the form I'm trying to create. Basically, it does not allow me to send the email to the recipient, even though the PHP code is correct. Could it be the problem with TRIM PHP code?</p>
  
  <pre><code>&lt;?php
      if ($_POST['submit']) {
          if (empty($_Post['name'])  || 
              empty($_POST['email']) || 
              empty($_POST['comments'])) {
  
              $error = true;
          } 
          else {
  
              $to = "linardsberzins@gmail.com";
  
              $name = trim($_POST['name']);
              $email = trim($_POST['email']);
              $comments = trim($_POST['comments']);
  
              $subject = "Contact Form";
  
              $messages =  "Name: $name \r\n Email: $email \r\n Comments: $comments";
              $headers = "From:" . $name;
              $mailsent = mail($to, $subject, $message, $headers);
  
              if ($mailsent) {
                  $sent = true;
              }
          }
      }
  ?&gt;
  </code></pre>
  
  <p>My HTML is:</p>
  
  <pre><code>&lt;?php if($error == true){ ?&gt;
  
      &lt;p class="error"&gt;Text&lt;/p&gt;
  
  &lt;?php } if($sent == true) { ?&gt;
  
      &lt;p class="sent"&gt;Text&lt;/p&gt;
  
  &lt;?php } ?&gt;
  
  &lt;div id="form"&gt;
      &lt;form name="contact" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;
          &lt;fieldset&gt;
              &lt;h4&gt;Contact Me!&lt;/h4&gt;
              &lt;label for="name"&gt;Name:&lt;/label&gt;
                  &lt;input type="text" name="name" id="name"/&gt;
                  &lt;label for="email"/&gt;Email:&lt;/label&gt;
                  &lt;input type="text" name="email" id="email"/&gt;
                  &lt;label for="comments" id="comments"&gt;Comments:&lt;/label&gt;
                  &lt;textarea name="comments" id=""&gt;&lt;/textarea&gt;
                  &lt;fieldset&gt;
                      &lt;input class="btn" type="submit" name="submit"   class="submit" value="Send email"/&gt;
                      &lt;input class="btn" type="reset" value="Reset"/&gt;
                  &lt;/fieldset&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
  </code></pre>