title: Send contact form data to email
body: <p>My goal is to make a contact form, where the user would type their name, email and message. The moment they press "Send", me, as the admin, would receive an email with all the information that was typed in before. Right now the email is sent but its empty, for example:</p>
  
  <blockquote>
    <p>Reply to:<br>
    User name:<br>
    User email<br>
    User message</p>
  </blockquote>
  
  <p>Also, when I click on "Send message" it gives me the same form but without CSS, there must be a code mistake which I don't know what it is.</p>
  
  <pre class="lang-html prettyprint-override"><code>// Form contactos.php
  &lt;div class="col-md-7 mb-5 site-animate"&gt;
    &lt;form action="index.php?cmd=contform" method="post"&gt;
      &lt;div class="form-group"&gt;
        &lt;label for="name" class="sr-only"&gt;Name&lt;/label&gt;
        &lt;input type="text" class="form-control" id="NomeM" placeholder="Nome"&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;label for="email" class="sr-only"&gt;Email&lt;/label&gt;
        &lt;input type="text" class="form-control" id="EmailMen" placeholder="Email"&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;label for="message" class="sr-only"&gt;Messagem&lt;/label&gt;
        &lt;textarea name="message" id="Mensagem" cols="30" rows="10" class="form-control" placeholder="Escreva a sua mensagem"&gt;&lt;/textarea&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;input type="submit" name="submit" class="btn btn-primary btn-lg" value="Enviar Mensagem"&gt;
      &lt;/div&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <pre class="lang-php prettyprint-override"><code>//File contform.php
  
  &lt;?php
  $sql="select * from Mensagem ";
  $res=$lig-&gt;query($sql);
  $lin = $res-&gt;fetch_array();
  
  
  $NomeM = $_POST['NomeM'];
  $Email = $_POST['EmailMen'];
  $Mensagem = $_POST['Mensagem'];
  
  
  $email_from = 'admin03@happygreen.pt';
  
  $email_subject = "New Form Submission";
  
  $email_body = "User Name:" .$lin['NomeM']."\n".
  "User Email:".$lin['EmailMen']."\n".
  "User Message:".$lin['Mensagem']."\n";
  
  
  $to = "filipajoao1933@gmail.com";
  
  $headers = "De: $email_from \r\n";
  
  $headers .= "Responda a: ".$lin['EmailMen']."\r\n";
  
  mail($to,$email_subject,$email_body,$headers);
  
  header("Location: Contactos/contactos.php");
  
  ?&gt;
  </code></pre>