if(is_numeric($_POST['broj'])) { for($i=0; $i<$_POST['broj']; $i++) { echo '<input type="text" name="polje{$i}" />'; } }