Hello there.
I have a form that has a 3 fields that ask for a number. Each fields must have an input of 3 digits each, summing up will have a total of 9. However, the problem arise when the input is 0.
Example:
Field 1: 123
Field 2: 000
Field 3: 123
Whenever I check for validation of the total number of the 3 fields , it returns an error. I've seen that the Field 2 having the input of three 0's is not seen.
Here is my script:
<?php
$field1 = intval($_POST['field1']);
$field2 = intval($_POST['field2']);
$field3 = intval($_POST['field3']);
$fieldtotalsize = 9; //must be the total size constant
$fieldsize = strlen($field1) + strlen($field2) + strlen($field3);
if($fieldsize != $fieldtotalsize)
{
$disp = "Complete your input.";
}
else
{
echo "Success";
}
?>
Hope someone help me in this somehow simple problem for an advanced PHP programmer.