Is there anyway I can import all form variables (so i can call them from within a function), with one command?
I know I can just use global on them all, but it would be easier if theres a function to do it all for me.
Well, you could declare global $HTTP_POST_VARS or global $HTTP_GET_VARS
as appropriate, but that seems like more doodling around than it's worth.
// clean up the user's input: reset($HTTP_POST_VARS); //go to the first in array while(list($key, $val) = each($HTTP_POST_VARS)) //interate each posted $var { if (is_array($val))//if it's an array do this: { for ($i=0; $i < count($val); $i++){ $val[$i] = trim($val[$i]); $val[$i] = addslashes($val[$i]); $GLOBALS[$key] = $val[$i];//here's your globals bit } } else { $val = trim($val); $val = addslashes($val); $GLOBALS[$key] = $val; } }
🙂