I have the following situation:
<select name="n">
<option>Please fill</option>
<option value="0">0</option>
<option value="1">1</option>
</select>
Now, i pass the serialized form with Ajax. I correctly see this in the console's POST panel:
[...]&n=0&[...]
My php validation script check both if the field has been filled and, for security reasons, that it is a digit:
parse_str($_REQUEST['data'], $values);
if (!ctype_digit($values['n'])) {
array_push($err, 'n');
}
Can someone explain WHY if i'm passing the value 0 this check always fails? If i pass any other select option with a digit other than 0, it let me in... I tried also using is_numeric instead of ctype_digit (just to try) and it fails as well. But this makes no sense...as 0 is both numeric and digit!
UPDATE
if i var_dump($values['n'])
, i get that it is null...so is there any problem with the parse_str($_REQUEST['data'], $values)
?