title: store dynamically created elements' value to database PHP MySql
body: <p>newbie here.. I have a form where a user can click a button to add an input text element. I did this using JQuery. </p>
  
  <p>What I want to accomplish is to save the values of the dynamically added textboxes to the database. </p>
  
  <p>I have the following code below but storing to database is not working as it should be.</p>
  
  <p><strong>HTML Code:</strong></p>
  
  <pre><code>&lt;form id='myform' action='save.php' method='POST'&gt;
    &lt;input type='button' value='Add Another User' id='auser'&gt;
    &lt;input type='text' id='user' name='user'&gt;
    &lt;input type='submit' value='Save User/s' name='submit'&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>JQUERY code:</strong></p>
  
  <pre><code>$('#auser').on('click', function() {
     $('#myform').append("&lt;input type='text' id='user' name='user'&gt;");
  });
  </code></pre>
  
  <p><strong>PHP Code(success.php):</strong></p>
  
  <pre><code>&lt;?php
    if (isset($_POST['submit'])){
    $username =  $_POST['user'];
    $qry=$con-&gt;prepare('INSERT INTO userslist (username) VALUES (?)')
    $qry-&gt;execute(array($username));
    }
  
  ?&gt;
  </code></pre>
  
  <p>thanks in advance for any help..</p>