title: How to fix 'Send Message has failed' error in PHP - Submit Button HTML not working
body: <p>i'm coding my very first own website. there is a section where you can enter your name, mail and a message to me. 
  by clicking "send message" the message should be sent to my personal mail. 
  the website visitor should receive an alert via a pop-up "message has been sent successfully" or sth like that. 
  sadly, when clicking "send message" an additional website is opened stating "failed to sent message".
  any help is MUCHLY appreciated.</p>
  
  <p>html: </p>
  
  <pre><code>&lt;form action="untitled.php" method="post" target="self"&gt;
        &lt;p&gt;&lt;input class="w3-input w3-border" type="text" id="name" name="name" placeholder="Name" required name="Name"&gt;&lt;/p&gt;
        &lt;p&gt;&lt;input class="w3-input w3-border" type="email" id="email" name="email" placeholder="Email" required name="Email"&gt;&lt;/p&gt;
        &lt;p&gt;&lt;textarea id="message" type="text" name="message" required placeholder="Message" rows="6" cols="30" &gt;&lt;/textarea&gt;
        &lt;/p&gt;
  
          &lt;button class="w3-button w3-black" type="submit" name="submit" value="submit"&gt;
            &lt;i class="fa fa-paper-plane"&gt;&lt;/i&gt; Sende Nachricht
          &lt;/button&gt;
        &lt;/p&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>php: code</p>
  
  <pre><code>&lt;?php
  $posted = false;
  if( $_POST ) {
      $posted = true;
  
      $to = 'xx@gmail.com';
  
      $name = $_POST['name'];
      $mail_from = $_POST['email'];
      $subject = 'Message sent from website';
      $message = $_POST['message'];
  
      $header = "From: $name &lt;$mail_from&gt;";
  
      $result = $_POST['name'] == "danny"; // Dummy result
  }
  ?&gt;
  
     &lt;html&gt;
     &lt;head&gt;&lt;/head&gt;
    &lt;body&gt;
  
   &lt;?php
  if( $posted ) {
      if( $result )
          echo "&lt;script type='text/javascript'&gt;alert('submitted    successfully!')&lt;/script&gt;";
      else
          echo "&lt;script type='text/javascript'&gt;alert('failed!')         &lt;/script&gt;";
  }
  ?&gt;
    &lt;form action="" method="post"&gt;
    Name:&lt;input type="text" id="name" name="name"/&gt;
     &lt;input type="submit" value="submit" name="submit"/&gt;
   &lt;/form&gt;
   &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>