title: PHP - Contact Form Not Working
body: <p>Can you tell me why this code is not working? This is a basic PHP - HTML contact form... </p>
  
  <pre><code>&lt;?php 
      $errors = array();
  
      if (isset($_POST['name'], $_POST['email'])) {
  
          $name  = htmlentities(mysql_real_escape_string($_POST['name']));
          $email = htmlentities(mysql_real_escape_string($_POST['email']));
          $ip    = $_SERVER['REMOTE_ADDR'];
  
          if (empty($name) || empty($email)) {
            $errors[] = '&lt;div id="error"&gt;All fields are required.&lt;/div&gt;';
          } 
  
          if (strlen($name)&gt;25 || strlen($email)&gt;1024) {
            $errors[] = '&lt;div id="error"&gt;One or more fields exceeded the character limit.&lt;/div&gt;&lt;br /&gt;';
          } 
  
          if (empty($errors)) {
              function email($to, $subject, $body) {
                  mail($to, $subject, $body, 'From: support@astrominds.in');
              }
              email("abc@xyz.com", "Contact Message"," Your Subject: $subject\n" . "Ip: $ip\n" . " Your Name: $name\n" . " Your Email: $email\n");
          } 
      }
  ?&gt;
  </code></pre>
  
  <p>This is the html form...</p>
  
  <pre><code>&lt;form method="post" action="index.php"&gt;
      &lt;label class="label"&gt;Name&lt;/label&gt;
      &lt;input type="text" name="name" id="name" class="detail"  autocapitalize="words" autocorrect="off"&gt;
  
      &lt;label class="label"&gt;Email&lt;/label&gt;
      &lt;input type="text" id="f1" class="detail" name="email" autocapitalize="words" autocorrect="off" /&gt;
  
      &lt;input type="submit" value="Continue" class="csssubmit" &gt;
  </code></pre>