Magic_quotes

Hello!

Is there are more efficient way for dealing with magic quotes for every single $POST than checking to see if they’re on and if they are then StripSlashing away? From searching on-line some hosts will allow you to change the config file while others won’t. :frowning:

I’m hoping for something that I could do once and then absolutely forget about it, regardless of whether I keep my current host or have to change hosts 5 years down then line…

Thank you,

Eric

from the comments on the magicquotes page, I see this…


foreach ($_POST as $key => &$val) $val = filter_input(INPUT_POST, $key);

Cant say i’ve used that before personally, but there ya go.

Either way, you’re going to need a piece of code to do what you require. So, no not really.

Thanks!

In terms of implementing this, am I correct in thinking that I can just put it at the top of any page for which I JUST $POSTed values in order for it to do its magic (so to speak)?

In other words, something like this:

foreach ($_POST as $key => &$val) $val = filter_input(INPUT_POST, $key);
$var1 = $_POST[‘stuff_from_other_page_form’];
$var2 = $_POST[‘more_stuff_from_other_page_form’];

The foreach would then look for anything that was just posted and then convert it (if need be). My $var1 and $var2 would then be cleansed or not as appropriate to whether magicquotes is enabled?

magicquotes is deprecated and on the way out the door; that foreach loop will filter and update all values in $_POST.

Thanks! It can’t be deprecated fast enough. :slight_smile: