title: How to send a message using form (html) and php to send message?
body: <p>I am using this form code in html to make a contact form on my website:</p>
  
  <pre><code>&lt;form method="post" action="contact.php"&gt;
      &lt;p&gt;
          &lt;label for="name"&gt;Name&lt;/label&gt;
          &lt;input type="text" id="name" name="name" /&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label for="email"&gt;Email&lt;/label&gt;
          &lt;input type="text" id="email" name="email" /&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;label for="message"&gt;Message&lt;/label&gt;
          &lt;textarea id="message" name="message" rows="6" cols="30"&gt;&lt;/textarea&gt;
      &lt;/p&gt;
      &lt;p&gt;
          &lt;input type="submit" name="send" value="Send message" /&gt;
      &lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is the php code that I'm using to get the contact form sent to my email address:</p>
  
  <pre><code>&lt;?php
     if(isset($_POST['send'])) {
     // Prepare the email
     $to = 'someone@example.com';
     $subject = 'Message sent from website';
     $message = $_POST['message'];
     // Send it
     $sent = mail($to, $subject, $message);
     if($sent) {
     echo 'Your message has been sent successfully!';
     } else {
     echo 'Sorry, your message could not send.';
     }
     }
  ?&gt;
  </code></pre>
  
  <p>I cannot get it to send to my email address. I've made it live to try it but it still doesn't work and I don't know what I'm doing wrong. How can I get the user the send the email to my email address - have it sent to my email address so that I can see the message in my email? (Please help)</p>