Thank you devinemke. I am new to PHP and appreciate very much you help. The firstname and lastname are two separate text fields on the form and a corresponding field for firstname and lastname exists in the database table called users.
else
{
$names = explode("\n", $_POST['names']);
foreach ($names as $value)
{
$value = trim($value);
echo "INSERT INTO table SET name = '$value'<br>";
}
}
Can you help to modify the above code to capture firstname and lastname as separate fields to enter in the database, please. Would this work:
else
{
$names = explode("\n", $_POST['names']);
foreach ($firstname as $firstnamevalue, $lastname as $lastnamevalue)
{
$firstnamevalue = trim($firstnamevalue);
$lastnamevalue = trim($lastnamevalue);
echo "INSERT INTO table SET firstname = '$firstnamevalue', lastname = '$lastnamevalue'<br>";
}
}
I am not clear how the code is going to identify each row on the form when the submit button is clicked. Is the name of each field firstname and lastname is going to be the same for each row on the form?
Thank you.