1
I don’t know if they are all values, but in general, PHP takes everything as string when it comes from a form. Say I want to validate the 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 receive as string the information from "acts" and enters the if
, even though I’m typing 14
in the form, for example. So, how to validate certain values in PHP if (almost?) all are received from the form as string?
Examples will be welcome.
What is the difference between Sanitize and filter in php?
– rray