note 39259 deleted from function.stripslashes by aidan
| From: | aidan@php.net | Date: | Sun, 29 Aug 2004 10:22:37 +0000 |
| Subject: | note 39259 deleted from function.stripslashes by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75530@lists.php.net to get a copy of this message | ||
Note Submitter: no at user dot com
----
stripslashes() will kill your php associative form field[] names. Here is a method from my general
application object that solved the problem:
function Input($f_name) {
$f_data = $_REQUEST[$f_name];
if ($f_data) {
if (get_magic_quotes_gpc()) {
if (is_array($f_data)) {
foreach ($f_data as $key => $value) {
$array[$key] = stripslashes($value);
}
return $array;
} else {
return stripslashes($f_data);
}
} else {
return $f_data;
}
} else {
return "";
}
}
Note: I run this on all my php apps for consistency only. I have other functions that handle
escaping when necessary.