The ultimate clean/secure function

后端 未结 7 2255
忘掉有多难
忘掉有多难 2020-11-22 03:11

I have a lot of user inputs from $_GET and $_POST... At the moment I always write mysql_real_escape_string($_GET[\'var\'])..

I

7条回答
  •  广开言路
    2020-11-22 03:31

    i used that pass array or get , post

    function cleanme(&$array)
    { 
     if (isset($array))
     {
         foreach ($array as $key => $value)
         {
              if (is_array($array[$key]))
              {
               secure_array($array[$key]);
              }
              else 
              {
                $array[$key] = strip_tags(mysql_real_escape_string(trim($array[$key])));
              }
         }
     }
    }
    

    Usage :

    cleanme($_GET);   
    cleanme($_POST);
    

提交回复
热议问题