title: I want to pop a modal when fname already exist in DB
body: <p><strong>Form:</strong></p>
  
  <pre><code>&lt;form class="form-horizontal" data-toggle="validator" method="post" role="form" id="enquiryForm"&gt;
     &lt;div class="form-group"&gt;
        &lt;label class="col-lg-2 control-label"&gt;Full Name :&lt;/label&gt;
        &lt;div class="col-lg-8"&gt;
           &lt;input type="text" name="fname" class="form-control" id="inputFirstName" data-error="Please fill out this field." placeholder="Full Name" required&gt;
           &lt;div class="help-block with-errors"&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;button type="button" class="btn btn-info" id="existName"&gt;Next&lt;/button&gt;
     &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>AJAX:</strong></p>
  
  <pre><code>$('#existName').click(function(){
      var fname = $('#inputFirstName').val();
      var datas = "fname="+fname;
      console.log(datas);
      $.ajax({
          url : "exist.php",
          data : datas,
          method : "POST"
      }).done(function(exist){
         console.log(exist);
          $('#existNameModal').html(exist);
      })
  })
  </code></pre>
  
  <p><strong>PHP:</strong></p>
  
  <pre><code>&lt;?php
     session_start();
     $companydata = $_SESSION['company'];
     $idCompany = $companydata['id'];
     $fnameCompany = $companydata['fname'];
     $lnameCompany = $companydata['lname'];
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
     &lt;head&gt;
        &lt;title&gt;&lt;/title&gt;
         &lt;!DOCTYPE html&gt;
         &lt;html lang="en"&gt;
            &lt;head&gt;
               &lt;!-- Latest compiled and minified CSS --&gt;
               &lt;!-- jQuery library --&gt;
               &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt;
  
               &lt;!-- Latest compiled JavaScript --&gt;
               &lt;script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
           &lt;/head&gt;
              &lt;body&gt;
                 &lt;?php   
                    $dbhost = "localhost";
                    $dbusername = "root";
                    $dbpassword = "";
                    $dbname = "gym";
                    $conn = mysqli_connect($dbhost, $dbusername, $dbpassword, $dbname) or die ("could not connect");
                    if($_POST){
  
                       $existName = $_POST['fname'];
                       $sql = "SELECT count(fname) from enquiry where fname = '$existName' AND cmpId = '$idCompany'";
                       $result = mysqli_query($conn, $sql);
                       $row = mysqli_num_rows($result);
                       print_r($row);
                       /*exit;*/
                       if(($row)&gt;0) {
                       $modal =  '
                       &lt;div class="modal-dialog"&gt;
                       &lt;!-- Modal content--&gt;
                       &lt;div class="modal-content"&gt;
                        &lt;div class="modal-header"&gt;
                          &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
                          &lt;h4 class="modal-title"&gt;Modal Header&lt;/h4&gt;
                        &lt;/div&gt;
                        &lt;div class="modal-body"&gt;
                          &lt;p&gt;Some text in the modal.&lt;/p&gt;
                        &lt;/div&gt;
                        &lt;div class="modal-footer"&gt;
                          &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
                        &lt;/div&gt;
                      &lt;/div&gt;
  
                    &lt;/div&gt;'; 
                      echo $modal;
                      }   
                      }
                  ?&gt;
              &lt;/body&gt;
          &lt;/html&gt;
  </code></pre>
  
  <p><strong>Modal HTML</strong></p>
  
  <pre><code>&lt;!-- Name exist Modal --&gt;
  &lt;div id="existNameModal" class="modal fade" role="dialog"&gt;
  &lt;/div&gt;                
  </code></pre>
  
  <p>I am trying to get this Modal display when count(fname) in DB is more than 0. I tried everything but nothing worked.</p>