title: how to insert data into phpmyadmin table using bootstrap form
body: <p><strong>how to insert data to phpmyadmin using save button in modal</strong></p>
  
  <blockquote>
    <p>what can code can i use for, so that i can insert data to phpmyadmin coming from the bootstrap modal. very thankful for those who will answer my question.</p>
  </blockquote>
  
  <p><a href="http://i.stack.imgur.com/5saFA.png" rel="nofollow">here is the picture of my phpmyadmin tbl_books</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?php
   $server = "localhost";
   $user = "root";
   $pw = "";
   $db = "b1_bm";
  
   $conn = mysql_connect($server,$user,$pw);
   
   if(!$conn) {
    die('could not connect: ' . mysql_error());
    
   }
   
   mysql_select_db($db, $conn);
  
   
  
  
   
  ?&gt;</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>table{
    border-collapse: collapse;
    width: 100%;
  }
  
  th, td{
   text-align: center;
   padding: 8px;
  }
  
  tr:nth-child(even) {
   background-color: #primary;
  }
  
  th{
   background-color: #4CAF50;
   color: white;
  }
  
  #btnsubmit{
   background-color: #4CAF50;
   color: white;
   border: 0px;
   width: 60px;
   height: 30px;
   border-radius: 10px;
   cursor:pointer;
  }
  
  #txtsearch{
   height: 20px;
   width: 190px;
  }
  
  
  #form-search{
   margin-right: 0px;
   margin-left: 1070px;
  }
  
  #btnAddBook{
   position: absolute;
   
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
   &lt;head&gt;
    &lt;link href = "css/style.css" rel = "stylesheet"/&gt;
    &lt;script type = "text/javascript" src = "js/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script type = "text/javascript" src = "js/bootstrap.min.js"&gt;&lt;/script&gt;
    &lt;link href = "css/bootstrap.min.css" rel = "stylesheet"/&gt;
   &lt;/head&gt;
   
   &lt;body&gt;
   
    &lt;form id="form-search" action = " main.php" method = "post"&gt; 
    &lt;input id="txtsearch" type = "text" name= "search" placeholder ="Enter keyword here..."/&gt;
    &lt;input id="btnsubmit" type = "submit" name= "submit" value= "Go"/&gt;
    &lt;/form&gt;
    &lt;hr&gt;
    &lt;br&gt;
    &lt;div class = "table"&gt;
     &lt;table&gt;
      &lt;tr&gt;
       &lt;th&gt;ISBN&lt;/th&gt;
       &lt;th&gt;Book Title&lt;/th&gt;
       &lt;th&gt;Book Author&lt;/th&gt;
       &lt;th&gt;Genre&lt;/th&gt;
       &lt;th&gt;Year Published&lt;/th&gt;
       &lt;th&gt;Description&lt;/th&gt;
      &lt;/tr&gt;
     &lt;?php 
      include('connection.php');
      
      
      
      
      if(isset($_POST['submit'])) {
      
      $sql = "Select * from tbl_books where isbn like '$search'";
      $result = mysql_query($sql, $conn);
      
       while($row = mysql_fetch_array($result)) {
     
      echo "&lt;tr&gt;
         &lt;td&gt; ". $row['isbn'] ."&lt;/td&gt;
         &lt;td&gt; ". $row['title'] ."&lt;/td&gt;
         &lt;td&gt; ". $row['author'] ."&lt;/td&gt;
         &lt;td&gt; ". $row['genre'] ."&lt;/td&gt;
         &lt;td&gt; ". $row['year_published'] ."&lt;/td&gt;
         &lt;td&gt; ". $row['description'] ."&lt;/td&gt;
     
      &lt;/tr&gt;";
      
       }
      } else {
      $sql = "Select * from tbl_books";
      $result = mysql_query($sql, $conn);
      
      while($row = mysql_fetch_array($result)) {
     
      echo "&lt;tr&gt;
       &lt;td&gt; ". $row['isbn'] ."&lt;/td&gt;
       &lt;td&gt; ". $row['title'] ."&lt;/td&gt;
       &lt;td&gt; ". $row['author'] ."&lt;/td&gt;
       &lt;td&gt; ". $row['genre'] ."&lt;/td&gt;
       &lt;td&gt; ". $row['year_published'] ."&lt;/td&gt;
       &lt;td&gt; ". $row['description'] ."&lt;/td&gt;
     
      &lt;/tr&gt;";
      
      }
      }
      mysql_close($conn);
     ?&gt; 
     &lt;/table&gt;
    &lt;/div&gt;
    &lt;div class = "container"&gt;
    &lt;button id = "btnAddBook" type = "button" class = "btn btn-success" data-toggle = "modal" data-target = "#myModal"&gt;Add Book&lt;/button&gt;
   &lt;div class = "modal fade" id = "myModal" role="dialog"&gt;
    &lt;div class = "modal-dialog"&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;Add Book&lt;/h4&gt;
      &lt;/div&gt;
      &lt;div class = "modal-body"&gt;
       &lt;form role = "form"&gt;
        &lt;div class = "form-group"&gt;
         &lt;label for = "exampleInputIsbn"&gt;ISBN&lt;/label&gt;
         &lt;input name = "isbn" type = "text" class = "form-control" placeholder = "Enter ISBN"&gt;
        &lt;/div&gt;
        
        &lt;div class = "form-group"&gt;
         &lt;label for = "exampleInputTitle"&gt;TITLE&lt;/label&gt;
         &lt;input name = "title" type = "text" class = "form-control" placeholder = "Enter the title of the book"&gt;
        &lt;/div&gt;
        
        &lt;div class = "form-group"&gt;
         &lt;label for = "exampleInputAuthor"&gt;AUTHOR&lt;/label&gt;
         &lt;input name = "author" type = "text" class = "form-control" placeholder = "Enter the author of the book"&gt;
        &lt;/div&gt;
        
        &lt;div class = "form-group"&gt;
         &lt;label for = "exampleInputGenre"&gt;GENRE&lt;/label&gt;
         &lt;input name = "genre" type = "text" class = "form-control" placeholder = "Enter the genre"&gt;
        &lt;/div&gt;
        
        &lt;div class = "form-group"&gt;
         &lt;label for = "exampleInputYearPublished"&gt;YEAR PUBLISHED&lt;/label&gt;
         &lt;input name = "year" type = "text" class = "form-control" placeholder = "Year published"&gt;
        &lt;/div&gt;
        
        &lt;div class = "form-group" method = "post"&gt;
         &lt;label for = "exampleInputDescription"&gt;DESCRIPTION&lt;/label&gt;
         &lt;input name = "description" type = "text" class = "form-control" placeholder = "Description"&gt;
        &lt;/div&gt;
       &lt;/form&gt;
       
      &lt;/div&gt;
      &lt;div class = "modal-footer"&gt;
       &lt;button name ="save" type = "button" class = "btn btn-success" data-dismiss = "modal"&gt;Save&lt;/button&gt;
  
       
      &lt;/div&gt;
       
     &lt;/div&gt;
    &lt;/div&gt;
   &lt;/div&gt;
    &lt;/div&gt;
    
      
   &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>