Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/03/2009, 09:12
Avatar de jakoujan
jakoujan
 
Fecha de Ingreso: septiembre-2005
Ubicación: Mexico DF
Mensajes: 26
Antigüedad: 18 años, 7 meses
Puntos: 1
Respuesta: Permitir solo numeros y letras

Exacto asi como dice the_web_saint yo tengo este script para evitar inyeccion

Código PHP:
<?
// Evitamos la inyeccion SQL

// Modificamos las variables pasadas por URL
foreach( $_GET as $variable => $valor ){
$_GET $variable ] = str_replace "'" "" $_GET $variable ]);
$_GET $variable ] = str_replace "\"" "" $_GET $variable ]);
}
// Modificamos las variables de formularios
foreach( $_POST as $variable => $valor ){
$_POST $variable ] = str_replace "'" "" $_POST $variable ]);
$_POST $variable ] = str_replace "\"" "" $_POST $variable ]);
$_POST $variable ] = str_replace "á" "&aacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "é" "&eacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "í" "&iacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "ó" "&oacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "ú" "&uacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "Á" "&Aacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "É" "&Eacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "Í" "&Iacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "Ó" "&Oacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "Ú" "&Uacute;" $_POST $variable ]);
$_POST $variable ] = str_replace "ñ" "&ntilde;" $_POST $variable ]);
$_POST $variable ] = str_replace "Ñ" "&Ntilde;" $_POST $variable ]);
}
?>
a parte que nos resuelve el problema de las letras tildadas y las Ñ ñ ahi puedes cambiar datos o incluso podrias poner un script con expresiones regulares para eliminar los datos y caracteres que no te sirvan.

Saludos.