Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/03/2007, 13:58
Avatar de AbdelioR
AbdelioR
 
Fecha de Ingreso: septiembre-2006
Ubicación: Tarragona
Mensajes: 926
Antigüedad: 17 años, 7 meses
Puntos: 8
Re: Evitar sql injection?

Que opinais de esta funcion para evitar este problema? me la ha pasado un amigo y quiero saber que opinais vosotros :)

Código PHP:
  function antiinjection($str)
  {
    
$banwords = array ("'"","";""--"" or "")""("" OR "" and "" AND ","/n","/r");
      if ( 
eregi "[a-zA-Z0-9]+"$str ) )
      {
        
$str str_replace $banwords'', ( $str ) );
      } else {
        
$str NULL;
      }
    
$str trim($str);
    
$str strip_tags($str);
    
$str stripslashes($str);
    
$str addslashes($str);
    
$str htmlspecialchars($str);
     return 
$str;
  } 
Saludos.