just a note:
if the server settings may be changed (i.e. if the server is not under your control), it may be worth considering to make it work with both possible scenarios, like
if(get_magic_quotes_gpc())
{
$_POST = array_map("stripslashes", $_POST);
}
o you may loose backslashes that were actually meant to be there (though this is less likely than quotes - actually it may be the harder to detect).
credits to ddenicola who posted this in the user contributed notes at php.net, I struggled with this quite a lot and found his/her solution very helpful.