Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/07/2015, 10:00
camaleon159
 
Fecha de Ingreso: julio-2015
Mensajes: 1
Antigüedad: 8 años, 9 meses
Puntos: 0
problema con validacion

buen día con todos, espero que puedan ayudarme soy nuevo en esto de programacion en php. gracias ante todo, aca esta mi problema



nuevo_usuario.php
Código HTML:
<form action="<?php echo $editFormAction; ?>" id="crear_usuario" name="crear_usuario" method="POST">
  <table width="398" border="0" cellspacing="4">
    <tr>
      <td width="222">Nombre</td>
      <td width="160"><label>
        <input name="nombre" type="text" id="nombre" />
      </label></td>
    </tr>
    <tr>
      <td>Usuario</td>
      <td><label>
        <input name="usuario" type="text" id="usuario" />
      </label></td>
    </tr>
    <tr>
      <td>Email</td>
      <td><label>
        <input name="email" type="text" id="email" />
      </label></td>
    </tr>
    <tr>
      <td>Clave</td>
      <td><label>
        <input name="clave" type="password" id="clave" />
      </label></td>
    </tr>
    <tr>
      <td>Avatar</td>
      <td><label>
        <select name="avatar" id="avatar" onchange="cambiarAvatar();">
          <option value="01.gif">gara</option>
          <option value="02.gif">sasuke</option>
          <option value="03.gif" selected="selected">narutosmile</option>
          <option value="04.gif">narutoscreamed</option>
          <option value="05.gif">kakashi</option>
          <option value="06.gif">neji</option>
          <option value="07.gif">itachi</option>
          <option value="08.gif">shino</option>
          <option value="11.jpg">jiraiya</option>
        </select>
		<img src="avatar/02.jpg" name="img_avatar" width="100" height="100" id="img_avatar" /></label></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><label>
      <input type="submit" name="submit" value="Crear Usuario" />
      </label></td>
    </tr>
  </table>
  
  
  <div align="center"> </div>
  
  
  
  <input type="hidden" name="MM_insert" value="crear_usuario">
</form>



bienvenido.php
Código PHP:
<?php

if(isset($_POST["submit"])){

$username trim(htmlentities(mysql_real_escape_string($_POST["usuario"]))); 
$email trim(htmlentities(mysql_real_escape_string($_POST["email"]))); 
$pass1 trim(htmlentities(mysql_real_escape_string($_POST["clave"]))); 
$avatar trim(htmlentities(mysql_real_escape_string($_POST["avatar"]))); 
//$web = trim(htmlentities(mysql_real_escape_string($_POST["web"]))); 


if(strlen($username) <or strlen($username)>=16){ 
?>
<script>
alert("Error Debe ingresar un valor 3-16 para el texto usuario");
window.location.href="nuevo_usuario.php";
</script>
<?php
}

if(
strlen($pass1) <or strlen($pass1)>=16){ 
?>
<script>
alert("Error Debe ingresar un valor 3-16 contraseña ");
window.location.href="nuevo_usuario.php";
</script>
<?php
}


if(
preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/"$email)) { 
    echo 
'email válido';
}

 }
?>

Lo que trato de hacer es que se muestre un mensaje de error debido a que ingreso un rango no establecido en el campo y de que se redireccione a la pagina nuevo_usuario.php otra vez(Solamente pasara a bienvenido si es que todo esta correcto pero me sale un mensaje de Column 'usuario' cannot be null al dar click sin rellenar el campo usuario en vez de mi mensaje .....lo mismo con los demas campos. alguien puede orientarme ? por favor