if ((!empty($_POST['val'])) and (!isset($_COOKIE['user_id']))) {
$value = $_POST['val'];
$value = filter_var($value, FILTER_VALIDATE_INT, array("options" =>
array('min_range' => 1, 'max_range' => 5)));
if ($value == false) {
echo 'bad'; exit;
}
echo 'ok';
$value = intval($_POST['val']);
if ($value >= 1 && $value <= 5) {
echo 'ok';
} else {
echo 'error';
}