从具有相同名称的文本字段提交多个值

i have a form, the carries two textfields with the name attributes "name" and "amount"

<form method="post" name="form1" id="form1" action="test.php">
<input type="text" name="name" value="wole" size="32" required="required" />
  <input type="text" name="amount" value="100" size="32" required="required" />
  <input type="text" name="name" value="yetunde" size="32" required="required" />
  <input type="text" name="amount" value="200" size="32" required="required" />
</form>

my intention is to capture name and amount side by side in two rows, based on how my form is structured.

i have tried submittin the data into the database using this snippet

$sql="INSERT INTO records(name,  amount)VALUES('$_POST[name]', '$_POST[amount]')";

but it only submits one row of data, "wole and 100", how can i make sure i capture the two different rows from my form

As requested, here is the full code. I added a new field "score" to show you how to add new fields.

<form method="post" name="form1" id="form1" action="test.php">
  <input type="text" name="studentname[]" value="wole" size="32" required="required" />
  <input type="text" name="course[]" value="100" size="32" required="required" />
  <input type="text" name="score[]" value="100" size="32" required="required" />
  <input type="text" name="studentname[]" value="yetunde" size="32" required="required" />
  <input type="text" name="course[]" value="200" size="32" required="required" />
  <input type="text" name="score[]" value="100" size="32" required="required" />
</form>


<?php
$con=mysqli_connect
("localhost","root","famakin","results");
//Checkconnection
if(mysqli_connect_errno())
{
    echo"FailedtoconnecttoMySQL:".mysqli_connect_error();
}
foreach($_POST['studentname'] as $idx => $studentname) {
    $sql="INSERT INTO records(studentname,  course, score)VALUES('" . $studentname . "', '" . $_POST['course'][$idx] . "', '" . $_POST['score'][$idx] . "')";
    if(!mysqli_query($con,$sql))
    {
        die('Error:'.mysqli_error($con));
    }
}


echo '<META HTTP-EQUIV="Refresh" Content="0; URL=result.php">';
mysqli_close($con);
?>

You might want to use square brackets with form element names:

<input type="text" name="amount[]" value="100" size="32" required="required" />

in such a case you will receive an array of values in your $_POST['amount'] and then you are responsible for parsing it properly and inserting as many rows as you want, e.g. with foreach php loop or like.

you can use array notation in names

<form method="post" name="form1" id="form1" action="test.php">
<input type="text" name="name[]" value="wole" size="32" required="required" />
  <input type="text" name="amount[]" value="100" size="32" required="required" />
  <input type="text" name="name[]" value="yetunde" size="32" required="required" />
  <input type="text" name="amount[]" value="200" size="32" required="required" />
</form>

in php you can get theses as

   $_POST[amount][index_no_here];

Eventually you can put it in loop to alter for each index

As others have said, it might be best to just use an array of fields. If it absolutely has to be one field, you could just split the string into an array by some separator (comma, semi-colon, etc) in your business layer and then loop through it to create different records in the database.