How can magic_quotes_gpc affect the input data in PHP forms?

magic_quotes_gpc is a PHP configuration setting that automatically adds slashes to incoming data, which can lead to double escaping and corrupt data in forms. To solve this issue, you can check if magic_quotes_gpc is enabled and remove the slashes from the input data if necessary using the stripslashes() function.

if(get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes', $_POST);
    $_GET = array_map('stripslashes', $_GET);
    $_COOKIE = array_map('stripslashes', $_COOKIE);
}