I\'m trying to insert data from dynamically created add remove fields in database using php but unable to do.I\'m only able to insert data from original form.
My fo
Because you have a header the code will insert single row and do the header to the requested file. So, remove both the header.
You assign variables within a loop, but insert into database only once after the loop. Put your database insertion into the loop, as follows (I keep it short for better understanding of the idea):
for ($i=0; $i < count($_POST['ch_direction']); $i++ ) { // Here you start each loop
$ch_direction = trim($_POST["ch_direction"][$i]);
$ch_direction_through = trim($_POST["ch_direction_through"][$i]);
$reg_id= $_POST['reg_id'][$i];
$sql = "INSERT INTO bps_registration_charkilla (ch_direction, ch_direction_through,reg_id) VALUES (?, ?, ?)";
...
if($stmt = mysqli_prepare($conn, $sql)) ... // Here you prepare the statement for the current element in the loop
...
if(mysqli_stmt_execute($stmt)) ... // Here you actually insert current loop element into the database
...
} // End of the loop