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