Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/10/2006, 07:01
Avatar de [NiRVaNa]
[NiRVaNa]
 
Fecha de Ingreso: abril-2004
Ubicación: Someplace In The Middle Of Nowhere!
Mensajes: 325
Antigüedad: 22 años, 5 meses
Puntos: 6
restringir caracteres especiales

Buenas gente, estoy haciendo un formulario de registro de usuarios y necesito que solo se permitan letras, numero y algunos caracteres especiales.

Hice este codigo, pero no me funciono, hay alguna otra forma de hacerlo:
Código PHP:
<?php

for ($i = 1; $i <= 255; $i++) {
   if (
$i == 45) : $i = 46; endif;
   if (
$i == 48) : $i = 59; endif;
   if (
$i == 65) : $i = 92; endif;
   if (
$i == 93) : $i = 94; endif;
   if (
$i == 95) : $i = 96; endif;
   if (
$i == 97) : $i = 123; endif;
   if (
$i == 124) : $i = 125; endif;
   
$b = chr($i);
   if (
ereg($b, $user_name)) {
      echo 
"<h4 style=\"color: red;\">El nombre de usuarios solo puede contener numeros, letras y los caracteres: - _ [ ] | :</h4>";
   }
}

?>
Gracias...