I'd just add a for loop around both the display and validation and add the increment.
Something like:
<?php
if (isset($_POST["next2"]) || isset($_POST["next2_x"])) {
$WAFV_Redirect = "step2.php";
$_SESSION['WAVT_step2_279_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
for ($x=1; $x<=intval($_SESSION['numart_sess']); $x++) {
$WAFV_Errors .= WAValidateRQ(((isset($_POST["articolo_".$x .""]))?$_POST["articolo".$x .""]:"") . "",true,$x);
$WAFV_Errors .= WAValidateRQ(((isset($_POST["barcode_".$x .""]))?$_POST["barcode".$x .""]:"") . "",true,"2".$x);
}
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"step2_279");
}
}
?>
and then the display like:
<?php
for ($x=1; $x<=intval($_SESSION['numart_sess']); $x++) {
?>
<div class="form-group">
<label for="articolo_<?php echo($x); ?>">Articolo <?php echo($x); ?></label>
<input name="articolo_<?php echo($x); ?>" type="text" class="form-control" id="articolo_<?php echo($x); ?>" placeholder="Articolo" value="<?php echo(WA_getSavedFormValue("persist_step2","articolo_".$x ."")) ?>">
<?php
if (ValidatedField('step2_279','step2_279')) {
if ((strpos((",".ValidatedField("step2_279","step2_279").","), "," . "".$x ."" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<div class="errore_validazione">errore articolo </div>
<?php //WAFV_Conditional step2.php step2_279(1:)
}
}
}?>
</div>
<div class="form-group">
<label for="barcode_<?php echo($x); ?>">barcode <?php echo($x); ?></label>
<input name="barcode_<?php echo($x); ?>" type="text" class="form-control" id="barcode_<?php echo($x); ?>" placeholder="barcode" value="<?php echo(WA_getSavedFormValue("persist_step2","barcode_".$x .")) ?>">
<?php
if (ValidatedField('step2_279','step2_279')) {
if ((strpos((",".ValidatedField("step2_279","step2_279").","), "," . "2".$x ."" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<div class="errore_validazione">errore barcode </div>
<?php //WAFV_Conditional step2.php step2_279(2:)
}
}
}?>
</div>
<?php
}
?>