Jump to content

Recommended Posts

Oh I know. The server that it will be launched on won't have magic quotes. Thank God. All data that goes into the database is stripped of slashes if magic quotes is enabled. So, I have a bit of a fail safe. I should probably also add it to my output filter. But that might strip slashes that were intentionally put there.

That's what I have been using. However, say for example, when the user fails to register, I have to ouput their POST variables back into their designated fields so that the user doesn't have to refill everything. My input filter goes a little like:

 

if(get_magic_quotes_gpc() == 1){
$string = stripslashes($string);
}

 

However, those slashes aren't stripped if POST variables are being returned straight back to the page because of an error. Only data that is good to go and allowed into the db gets stripped.

Fixed Code:

<?php
//turn magic quotes off
ini_set("magic_quotes_gpc", "0");
set_magic_quotes_runtime(1); 
function stripper($stringvar){
    if (1 == get_magic_quotes_gpc()){
        $stringvar = stripslashes($stringvar);
    }
    return $stringvar; ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.