title: Email form not working (Php noobie)
body: <p>I just started learning php and my first project was to make a working contact form. I have typed up what I could, but for some reason there appears to be some sort of errors that php is not telling me. I have looked for solutions to the issue on another web forum like phpacademy, and to no avail. I finally came to try out stack overflow, since I have heard great things about this forum. Any help is appreciated, and thanks in advance.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;title&gt;Contact&lt;/title&gt;
  
      &lt;!-- Bootstrap --&gt;
      &lt;link href="css/bootstrap.min.css" rel="stylesheet"&gt;
      &lt;link rel="stylesheet" href="css/styles.css"/&gt;
  
      &lt;!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --&gt;
      &lt;!-- WARNING: Respond.js doesn't websites if you view the page via file:// --&gt;
      &lt;!--[if lt IE 9]&gt;
      &lt;script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"&gt;&lt;/script&gt;
      &lt;![endif]--&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  
      &lt;?php
  
      if ($_POST['submit']){
  
  
  if(!$_POST['firstname']){
  
  $error='&lt;br /&gt; Please Enter your first name';
  
  }
  
  if(!$_POST['lastname']){
  
  $error='&lt;br /&gt; Please Enter your last name';
  
  }
  
  if(!$_POST['email']){
  
  $error='&lt;br /&gt; Please Enter your email address';
  
  }
  
  if(!$_POST['phone']){
  
  $error='&lt;br /&gt; Please Enter your phone number';
  
  }
  
  if(!$_POST['message']){
  
  $error='&lt;br /&gt; Please Enter your message you would like to send';
  
  }
  
  if($_POST['email']!="" and !filter_var($_POST['email'],
  FILTER_VALIDATE_EMAIL)){
  
  $error.='&lt;br /&gt; Please enter a valid email address';
  
  }
  
  
  if($error){
  $result='&lt;div class="alert alert-danger"&gt;&lt;strong&gt;One or more errors has occurred&lt;/strong&gt;'.$error.'&lt;/div&gt;';
  }
  
  else {
  if (mail("casey@caseywoelfle.com", "Potential Client!", "FirstName: " .
  $_POST['firstname'] . "
  
  LastName ".$_POST['lastname'] ."
  
  Email: " .$_POST['email'] . "
  
  Phone: ".$_POST['phone']  . "  
  
  Comment: ".$_POST['comment'])) {
  
  
  $result = '&lt;div class="alert alert-success"&gt;&lt;strong&gt;Thank you!&lt;/strong&gt;I\'ll be in touch within 2 business days.&lt;/div&gt;';
  
  } else {
  
  
  $result = '&lt;div class="alert alert-danger"&gt; Sorry, there was an error sending your message. Please try again later.&lt;/div&gt;';
  
  }
  
  }
  
  }
  
  ?&gt;
  
  &lt;nav class="navbar"&gt;
      &lt;div class="container-full"&gt;
          &lt;!-- Brand and toggle get grouped for better mobile display --&gt;
          &lt;div class="navbar-header"&gt;
              &lt;button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"&gt;
                  &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt;
              &lt;/button&gt;
              &lt;a class="navbar-brand honey-sb" href="#"&gt;CW&lt;/a&gt;
          &lt;/div&gt;
  
          &lt;div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"&gt;
              &lt;ul class="nav navbar-nav navbar-right"&gt;
                  &lt;li&gt;&lt;a class="nLink" href="index.html"&gt;Home&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a class="nLink" href="about.html"&gt;About&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a class="nLink" href="portfolio.html"&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a class="nLink" href="contact.php"&gt;Contact&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/nav&gt;
  
  &lt;div class="container-fluid"&gt;
      &lt;div class="row contact-sec"&gt;
  
          &lt;div class="col-md-12"&gt;
                  &lt;form class="form-horizontal" method="post"&gt;
                          &lt;div class="well"&gt;
                          &lt;h1 class="text-center header"&gt;Contact Me&lt;/h1&gt;
                              &lt;h3 class="text-center"&gt;
                                  Do you have a project you would like me to take a look at or maybe you have an idea?&lt;br/&gt;Either
                                  way don’t hesitate to send me an email using the contact form or give me a call.
                              &lt;/h3&gt;
                          &lt;/div&gt;
  
                          &lt;div class="form-group"&gt;
                              &lt;span class="col-md-1 col-md-offset-2 text-center"&gt;&lt;i class="glyphicon glyphicon-user"&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;div class="col-md-6"&gt;
                                  &lt;input id="InputFirstName" name="firstname" type="text" placeholder="First Name" class="form-control"&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group"&gt;
                              &lt;span class="col-md-1 col-md-offset-2 text-center"&gt;&lt;i class="glyphicon glyphicon-user"&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;div class="col-md-6"&gt;
                                  &lt;input id="InputLastName" name="lastname" type="text" placeholder="Last Name" class="form-control"&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                          &lt;div class="form-group"&gt;
                              &lt;span class="col-md-1 col-md-offset-2 text-center"&gt;&lt;i class="glyphicon glyphicon-envelope"&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;div class="col-md-6"&gt;
                                  &lt;input id="InputEmail" name="email" type="text" placeholder="Email Address" class="form-control"&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                          &lt;div class="form-group"&gt;
                              &lt;span class="col-md-1 col-md-offset-2 text-center"&gt;&lt;i class="glyphicon glyphicon-earphone"&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;div class="col-md-6"&gt;
                                  &lt;input id="InputPhone" name="phone" type="text" placeholder="Phone" class="form-control"&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                          &lt;div class="form-group"&gt;
                              &lt;span class="col-md-1 col-md-offset-2 text-center"&gt;&lt;i class="glyphicon glyphicon-pencil"&gt;&lt;/i&gt;&lt;/span&gt;
                              &lt;div class="col-md-6"&gt;
                                  &lt;textarea class="form-control" id="InputMessage" name="message" placeholder="Enter your massage for us here. We will get back to you within 2 business days." rows="7"&gt;&lt;/textarea&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                          &lt;div class="well"&gt;
  
                              &lt;div class="form-group"&gt;
                              &lt;div class="col-sm-4 col-sm-offset-4 text-center"&gt;
                                  &lt;button type="submit" id="submit" name="submit" class="btn btn-primary btn-lg"&gt;Submit&lt;/button&gt;
                              &lt;/div&gt;
                              &lt;/div&gt;
  
                          &lt;/div&gt;
                  &lt;/form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  
  
  
  &lt;footer&gt;
      &lt;div class="container-fluid"&gt;
  
          &lt;div class="row" id="f-nav"&gt;
  
              &lt;div class="col-xs-6 col-sm-3 text-center" id="f-contact"&gt;
                  &lt;h2 class="footerbolder"&gt;Contact&lt;/h2&gt;
  
                  &lt;img src="images/ph.png" class="img-responsive" alt=""/&gt;
  
              &lt;/div&gt;
  
              &lt;div class="col-xs-6 col-sm-3 text-center" id="f-about"&gt;
                  &lt;h2 class="footerbolder"&gt;About Us&lt;/h2&gt;
  
                  &lt;img src="images/ph.png" class="img-responsive" alt=""/&gt;
  
              &lt;/div&gt;
  
              &lt;div class="col-xs-6 col-sm-3 text-center" id="f-services"&gt;
                  &lt;h2 class="footerbolder"&gt;Services&lt;/h2&gt;
  
                  &lt;img src="images/ph.png" class="img-responsive" alt=""/&gt;
  
              &lt;/div&gt;
  
              &lt;div class="col-xs-6  col-sm-3 text-center" id="f-follow"&gt;
                  &lt;h2 class="footerbolder"&gt;Follow Me&lt;/h2&gt;
  
                  &lt;img src="images/ph.png" class="img-responsive" alt=""/&gt;
  
              &lt;/div&gt;
  
          &lt;/div&gt;
  
          &lt;div class="row"&gt;
  
              &lt;div class="hidden-xs col-sm-12" id="pp-tos"&gt;
                  &lt;div class="center-block text-center"&gt;
                      &lt;a class="" href="#"&gt;Terms of Service&lt;/a&gt;
                      &lt;a&gt;|&lt;/a&gt;
                      &lt;a class="" href="#"&gt;Privacy Policy&lt;/a&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
  
  
  
      &lt;/div&gt;
  &lt;/footer&gt;
  
  
  
  
  
  &lt;!-- jQuery (necessary for Bootstrap's JavaScript plugins) --&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;!-- Include all compiled plugins (below), or include individual files as needed --&gt;
  &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/Fittext/jquery.fittext.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>