title: PHP Contact Form in a Bootstrap Modal
body: <p>Ok, I am new to this so any feedback is welcomed</p>
  
  <p>I would like to utilise a bootstrap modal as a contact form. I already have a contact form in php but how can I display this in a modal format</p>
  
  <p>Thank you, <h3>David</h3></p>
  
  <p>Here is the php form</p>
  
  <pre><code>&lt;?php
  
  if ($_POST["submit"]) {
  $result = '&lt;div class="alert alert-success"&gt;Form submitted&lt;/div&gt;';
  
    if (!$_POST['name']) {
      $error="&lt;br /&gt;Please enter your name";
    }
  
    if (!$_POST['email']) {
      $error.="&lt;br /&gt;Please enter your email address";
    }
  
     if (!$_POST['comment']) {
      $error.="&lt;br /&gt;Please enter a comment";
    }  
  
    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;There were error(s) with your form:&lt;/strong&gt; '.$error.'&lt;/div&gt;';
    } else {
  
     if (mail("david@naturallypizza.org", "Comment from website!",
  
  "You have an email from the website contact form\r\n"."
  Name: ".$_POST['name']."
  Email: ".$_POST['email']."
  Comment: ".$_POST['comment'])) {
  
      $result = '&lt;div class="alert alert-success"&gt;&lt;strong&gt;Thank you for your email! I\'ll get back to you soon&lt;/strong&gt;&lt;/div&gt;';
  
     } else {
  
        $result = '&lt;div class="alert alert-danger"&gt;&lt;strong&gt;Sorry there was an error with your message, please try again later!&lt;/strong&gt;&lt;/div&gt;';
        }
  
    }
  
    }
  ?&gt;
  
  &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;!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --&gt;
      &lt;title&gt;Contact Form&lt;/title&gt;
  
      &lt;!-- Bootstrap --&gt;
      &lt;link href="css/bootstrap.min.css" rel="stylesheet"&gt;
  
      &lt;!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --&gt;
      &lt;!-- WARNING: Respond.js doesn't work 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;style&gt;
  
  
      .emailForm {
  
          border:1px solid grey;
          border-radius: 10px;
          margin-top: 20px;
          padding-bottom: 10px;
  
      }
  
      textarea {
  
          height: 220px;
      }
  
    &lt;/style&gt;
  
  
  
  
  
  
    &lt;/head&gt;
  
  
  
  
    &lt;body&gt;
  
      &lt;div class="container"&gt;
  
          &lt;div class="row"&gt;
  
              &lt;div class="col-md-6 col-md-offset-3 emailForm"&gt;
               &lt;h1&gt;Contact us!&lt;/h1&gt;
  
  
               &lt;?php echo $result; ?&gt;
  
              &lt;p class="lead"&gt;Please get in touch!&lt;/p&gt;
  
              &lt;form method="post"&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;label for ="name"&gt;Your name:&lt;/label&gt;
                      &lt;input type="text" name="name" class="form-control" placeholder="Name" value= "&lt;?php echo $_POST['name']; ?&gt;"/&gt;   
                  &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;label for ="email"&gt;Your email:&lt;/label&gt;
                      &lt;input type="email" name="email" class="form-control" placeholder="Email" value="&lt;?php echo $_POST['email'];?&gt;"/&gt;   
                  &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;label for ="comment"&gt;Your comment:&lt;/label&gt;
                      &lt;textarea class="form-control" name="comment"&gt;&lt;?php echo $_POST['comment'];?&gt;&lt;/textarea&gt;
                  &lt;/div&gt;
  
                  &lt;input type="submit" name="submit" class="btn btn-success btn-lg" value ="submit"&gt;
  
  
  
              &lt;/form&gt; 
              &lt;/div&gt;
          &lt;/div&gt;
  
      &lt;/div&gt; 
  
  
      &lt;!-- jQuery (necessary for Bootstrap's JavaScript plugins) --&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/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;/body&gt;
  &lt;/html&gt;
  </code></pre>