I need to create 20 inputs which, when filled in, should show what was typed in them below, using arrays and foreach, here is the code below:
function repeteInput(){
for($i = 1; $i <= 20; $i++){
echo '<form action="repeteInput.php" method="post">';
echo 'Digite um número aqui ('.$i.')<input type="text" name "produto[]"><br>';
}
echo '<input type="submit" value="Enviar"></form>';
$produtos = $_POST['produto'];
foreach ($produtos as $produto){
echo $produto."<br>";
}
}
echo repeteInput();
I've already checked the code, and it looks exactly the same as what I copied in my notebook, which had worked on another PC. Even so, it shows this error after the page:
Notice: Undefined index: produto in C:\xampp\htdocs.04.2017\repeteInput.php on line 8
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs.04.2017\repeteInput.php on line 9