I've got some PHP code inserting things into a database....
I'm a little rusty on how to protect the data to prevent XSS and SQL injections, looking for some tips.
Would is_numeric() be efficient for userid/strangerid?
and
Is clean() good enough?
I'm a little rusty on how to protect the data to prevent XSS and SQL injections, looking for some tips.
PHP:
$userid = $_GET['userid'];
$strangerid = $_GET['strangerid'];
$message = clean($_GET['message']);
// and then clean() here:
/* functions used throughout the script */
function clean($data)
{
global $mysqli;
if (get_magic_quotes_gpc())
{
$data = stripslashes($data);
}
return strip_tags($mysqli->escape_string($data));
}
Would is_numeric() be efficient for userid/strangerid?
and
Is clean() good enough?








