input process with php - doubt
Posted: Fri Oct 31, 2008 10:32 am
I wrote a small function called "sanitize_input", when I had a problem with double quotes ( " ) and single quote ( ' ) which did not let my input being updated in the database.
I call this function with passing the POST and GET global variables before updating the input to the database. I am not using cookies or sessions extensively. So I am just enough with POST and GET. I wanted to know whether I am doing it correct? or I had to do this in a better way.
sanitize_input($_POST);
sanitize_input($_GET);
I call this function with passing the POST and GET global variables before updating the input to the database. I am not using cookies or sessions extensively. So I am just enough with POST and GET. I wanted to know whether I am doing it correct? or I had to do this in a better way.
sanitize_input($_POST);
sanitize_input($_GET);
Code: Select all
if ( ! get_magic_quotes_gpc() )
{
function sanitize_input(&$arr) {
foreach($arr as $key=>$value)
{
if (is_array($value))
{
sanitize_input($value);
}
$arr[$key] = addslashes($value);
}
}
}