Search code examples
phparraysmagic-quotes-gpc

Form wont return array when using this function to overcome magic quotes?


To counteract magic quotes I have this function set at the top of every page. However it seems to be affecting when I have an array in a form <input type="checkbox" name="check[]" />.

if ( in_array( strtolower( ini_get( 'magic_quotes_gpc' ) ), array( '1', 'on' ) ) ) {
    $_POST = array_map( 'stripslashes', $_POST );
    $_GET = array_map( 'stripslashes', $_GET );
    $_COOKIE = array_map( 'stripslashes', $_COOKIE );
}

I removed the function and it worked returning the full array when printing the array. However I need magic quotes off and also.

With the funciton I just get Array returned.

How can I change the function above or overcome this issue?

Thanks


Solution

  • There is an excellent page on the php website about how to disable magic quotes, both in the .ini file and at runtime. I highly suggest using their code instead of something homebaked.