I'm getting mad writing some code for sanitize the data which come from a form. In the form I have a input field named "sender_countryCode" that could only contains 2 or 3 text characters like USA, FR, EN, ... the following code should block everything different from a string but if i write "my text" in the field nothing pass the filter!
if (isset($_POST["sender_countryCode"])){
$var = $_POST["sender_countryCode"];
$var = stripslashes($var);
$var = htmlentities($var);
$var = strip_tags($var);
$var = filter_var($var, FILTER_SANITIZE_STRING);
$sender["countryCode"] = $var;
unset($var);
};