I use this php code to check the variable that I get from the URL to protect my Database from URL injection :
if(isset($_REQUEST["u_i"]))
{//echo $_REQUEST["u_i"];exit;
if(!is_numeric($_REQUEST["u_i"]))
{
//echo $_REQUEST["u_i"];exit;
header('Location:index.php');
}
else
{//echo $_REQUEST["u_i"];
$id_raw = trim(htmlentities($_REQUEST["u_i"]));
$visitor_id = mysql_real_escape_string($id_raw);
}
}
I want to know what should I edit in this code to use it on the $_POST
array variables (user input text not numbers) like (comments from users, text blocks) because I use this part to direct users to index if the url variable contain a text not number :
if(!is_numeric($_REQUEST["u_i"]))
{
//echo $_REQUEST["u_i"];exit;
header('Location:index.php');
}
so how could I check a variable which have text securely ?