Solutionabc
asked on
PHP FILTER_VALIDATE_INT
hi,
How would I validate a users integer input with this function?
I want the min number to be 0 and max to be 9.
and what if I have multiple user values that I want to validate do I put it in an array?
thanks!
How would I validate a users integer input with this function?
I want the min number to be 0 and max to be 9.
and what if I have multiple user values that I want to validate do I put it in an array?
thanks!
ASKER
If I have the code below, and verseQ = 10, will var_dump return false?
if it does how do I check the returned value?
if it does how do I check the returned value?
$verseQ = $_POST["verseQb"];
$int_verseQ = array("options"=>
array("min_range"=>0, "max_range"=>9));
var_dump(filter_var($verseQ, FILTER_VALIDATE_INT, $int_verseQ));
yes...
but if code not working then have to check what values is getting assigned to verseQ.
to make sure it always have integer value change the line to
$verseQ = $_POST["verseQb"] + 0;
but if code not working then have to check what values is getting assigned to verseQ.
to make sure it always have integer value change the line to
$verseQ = $_POST["verseQb"] + 0;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<?php
$intVal = $_REQUEST['FormField'];
if($intVal > 0 and $intVal < 9)
{
echo "valid no.";
}
else
{
echo "invalid";
}
?>