I do not know if they are all values, but in general, PHP gets everything as string when it comes from a form. Let's say I want to validate age:
<form method="POST" action="test.php">
<input type="text" name="age">
<button type="submit">Manda</button>
</form>
And in test.php
:
if(!is_int($_POST['age'])){
echo 'não é integer';
var_dump($_POST['age']);
}
You can see that using var_dump()
I get the information from " age " as a string and enter if
, even typing 14
on the form, for example. So how do I validate certain values in PHP if (almost?) All are received from the form as string ?
Examples will be welcome.