Get data from a array, sent by form with method post

Hello, after upgrade our PHP version to 5.3.2., some code stoped to show values from the array. [php]

Gerar Código de Barras <?}?>
  <? if ($_POST['botao']=="Consultar"){?>
Gerar Códigos de Barras
Nº Funcionário: " size="4" maxlength="4" class="input"> (4 dígitos)
.
[/php] The form send a 13 digit number and this code doesn't show any value:

[php]

<? function validateEan13($digits) { $originalcheck = false; if ( strlen($digits) == 13 ) { $originalcheck = substr($digits, -1); $digits = substr($digits, 0, -1); } elseif ( strlen($digits) != 12 ) { // Invalid EAN13 barcode return false; } // Add even numbers together $even = $digits[1] + $digits[3] + $digits[5] + $digits[7] + $digits[9] + $digits[11]; // Multiply this result by 3 $even = $even * 3; // Add odd numbers together $odd = $digits[0] + $digits[2] + $digits[4] + $digits[6] + $digits[8] + $digits[10]; // Add two totals together $total = $even + $odd; // Calculate the checksum // Divide total by 10 and store the remainder $checksum = $total % 10; // If result is not 0 then take away 10 if($checksum != 0){ $checksum = 10 - $checksum; } // Return results. if ( $originalcheck !== false ) { //return array('barcode'=>$digits, 'checksum'=>$checksum, 'originalcheck'=>$originalcheck); return $checksum; } else { //return array('barcode'=>$digits, 'checksum'=>$checksum); return $checksum; } } if ($_POST['ean']){ $CODIGO="290000"; $VALOR=$_POST['ean']; $barras= $CODIGO.$VALOR."00"; $DIGIT = $barras.validateEan13($barras); $EAN[]=$DIGIT; } ?> <? $a=0; echo ""; for ($i=0; $i<=(count($EAN)-1);$i++){ //for ($i=0; $i<3;$i++){ if ($a==0) echo ""; else if ($a==3){ echo ""; $a=0; } echo ""; //echo ""; $a++; } echo "
"; //print_r($EAN);?> [/php]

How can I get the values from the Array???

I can’t see in your code, where do you call your validateEan13() function, and what argument value do you pass to this function ($digits).

From your html form, it looks like your sending a 4 char variable named ean, and in your showEAN.php script this value is available as $_POST[‘ean’].

I Call here

if ($_POST[‘ean’]){
$CODIGO=“290000”;
$VALOR=$_POST[‘ean’];
$barras= $CODIGO.$VALOR.“00”;
$DIGIT = $barras.validateEan13($barras);
$EAN[]=$DIGIT;

}

Sponsor our Newsletter | Privacy Policy | Terms of Service