title: html drill down drop down selected value does not inserted in MYSQL
body: <p>i have two drop downs. first drop down populate from database. second drop down populated from database based on selected value of first drop down. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $("#c").change(function() {
      var c1 = $('#c :selected').text();
      if(c1 != "") {
        $.ajax({
          url:'getstatw.php',
          data:{c:c1},
          type:'POST',
          success:function(response) {
            var resp = $.trim(response);
            $("#c").html(resp);
          }
        });
      } else {
        $("#c").html("&lt;option value=''&gt;Select state&lt;/option&gt;");
      }
    });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;form id = "world" method="post" action="insert.php"&gt;
  &lt;select name="country" id="c" style = "width:200px" class="btn btn-primary dropdown-toggle" ;&gt;
        &lt;option&gt;country&lt;/option&gt;
    
        &lt;?php
            
        $sql = "select DISTINCT country from table1";
        $res = mysqli_query($con, $sql);
        if(mysqli_num_rows($res) &gt; 0) {
          while($row = mysqli_fetch_object($res)) {
            echo "&lt;option value='".$row-&gt;id."'&gt;".$row-&gt;c."&lt;/option&gt;";
      
          }
        }
        ?&gt;
      &lt;/select&gt;
  &lt;br&gt;&lt;br&gt;
    &lt;label for="s" &gt;State&lt;/label&gt;
  
  &lt;select name="State" id="s" style = "width:200px  " ; class="btn btn-primary dropdown-toggle";&gt;&lt;option&gt;Select state&lt;/option&gt;&lt;/select&gt;&lt;br&gt;&lt;br&gt;
  &lt;button id = "sub" type="submit" class="btn btn-primary" disabled&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
    </code></pre>
  </div>
  </div>
  </p>
  
  <p>insert.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$con=mysqli_connect("localhost","root","","world");
  
  // Check connection
  if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  // escape variables for security
  //home tab
  $c = mysqli_real_escape_string($con, $_POST['country']);
  $s = mysqli_real_escape_string($con, $_POST['state']);
  
  
  //query for table_mainast
  $sql1="INSERT INTO table1 (Country, State)
  VALUES ('$c', '$s',)";
  //query for table_dataast
  
  
  if (!mysqli_query($con,$sql1)) {
    die('Error: ' . mysqli_error($con));
  }
  
  echo "1 record added";
  
  mysqli_close($con); </code></pre>
  </div>
  </div>
  
  getstate.php</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;?php
  $con=mysqli_connect("localhost","root","","test");
  
  // Check connection
  if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  if(isset($_POST['c'])) {
    $sql = "select DISTINCT `State` from `table2` where `Country`='".mysqli_real_escape_string($con, $_POST['c'])."'";
    $res = mysqli_query($con, $sql);
    if(mysqli_num_rows($res) &gt; 0) {
       echo "&lt;option value=''&gt;------- Select --------&lt;/option&gt;";
      while($row = mysqli_fetch_object($res)) {
        echo "&lt;option value='".$row-&gt;id."'&gt;".$row-&gt;c."&lt;/option&gt;";
      }
    }
  } else {
    header('location: ./');
  }
  
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>i have tried almost all solution given on net. but do not understand my data is not inserted into mysql database. 
  <a href="https://stackoverflow.com/questions/35121363/how-to-insert-html-select-value-as-text-in-mysql-via-php">How to insert HTML select value as text in MySQL via PHP</a>
  <a href="https://stackoverflow.com/questions/42666685/php-drop-down-list-selected-value-not-inserted-in-the-database">PHP Drop down list selected value not inserted in the database</a></p>