I know these kinds of question has been asked multiple times in SO. But i am getting error in below code.
I have a form in modal box.
 <form method="post" action="<?php $_SERVER["PHP_SELF"];?>" role="form">
        <div class="modal-body">   
        <div class="row">
          <label class="col-xs-3 topjob_desc" for="title">Active list :</label>
          <div class="col-xs-8">
          <select class="form-control" id="title">
       <?php
            $total_view = $mysqli->prepare("SELECT id,title FROM posting where id= ?");
            $total_view ->bind_param("i", $id);
            $total_view->execute();
            $total_view->store_result();
            $total_view->bind_result($id,$name);
            while ($total_view->fetch()) {
               $name = $name;
               $id = $id;
    echo '<option value="'.$id.'">'.$name.'</option>';               
    }
?>
  </select>
</div></div>
<br />
    <div class="row">
      <label class="col-xs-3 topjob_desc" for="title1">Name</label>
      <div class="col-xs-8">
      <textarea class="form-control" rows="5" id="comment" name="comment">Message</textarea>
      </div>
    </div>
         </div>
        <div class="modal-footer">
            <input type="submit" class="btn btn-primary" id="submit" name="submit" value="Send" /> 
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
    </form>
Here is the code for form submit. Which is on the same page.
if (isset($_POST['submit'])) {
         $messages = $_POST['comment'];
        $id = $_POST['id'];
         $total_viewss = $mysqli->prepare("SELECT title,company_name FROM posting where emid= ? and jid=?");
            $total_viewss ->bind_param("si", $id,$jid);
            $total_viewss->execute();
            $total_viewss->store_result();
            $total_viewss->bind_result($title,$company);
            while ($total_viewss->fetch()) {
               $company = $company;
               $title=$title; 
               }
        $result = $mysqli->prepare("INSERT INTO user_messages (uid, profile_pic, company, title, id, messages,emid) VALUES (?, ?, ?, ?, ?, ?, ?)");
        $result ->bind_param("issssii", $uid, $profile_pic, $company, $title, $jid, $messages,$emid);
        $result->execute();
        $result->store_result();
    }
When i submit the form data is not getting saved in database. I am not sure what am i doing wrong. Please advise.
Please ignore typos.
