i am watching tutorials on PHP, and in the video there is this code:
$cntr = 1;
$item = 'dummy';
while(!empty($item))
{
$item_html_name = 'item'.$cntr;
$item = $_POST[$item_html_name];
if (!empty($item))
{
print "Item: ".$item."<br>";
$cntr++;
}
}
When i try the code, i get an error "Notice: Undefined index: item1"
here is a screenshot of the video:
or it may be because of the different PHP versions?
html are also the same:
<form action="code1.php" method="post">
<p>1 <input type="text" name="item1" size="30"></p>
<p>2 <input type="text" name="item2" size="30"></p>
<p>3 <input type="text" name="item3" size="30"></p>
<input type="submit" value="submit">