Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/07/2011, 09:38
Avatar de LuisCZ
LuisCZ
 
Fecha de Ingreso: noviembre-2009
Ubicación: Maracaibo
Mensajes: 127
Antigüedad: 14 años, 4 meses
Puntos: 0
Respuesta: Detener una ejecucion si se registra un usuario...

Cita:
Iniciado por jotaincubus Ver Mensaje
Bueno así queda que muy difícil (adivinando)... pon el código para ver el tipo de condiciones y como las estas manejando.
Hola jotaincubus, este es el codigo completo de registro de usuario:

Código:
<?php 
mysql_connect ("localhost", "root",""); 
mysql_select_db("Mybd") or die("Cannot select database"); 

if (isset($_POST["usuario"])) { 
$usuario = $_POST["usuario"]; 
$contrasena = $_POST["contrasena"]; 
$contrasenar = $_POST["contrasenar"];
$pais = $_POST["pais"]; 
$correo = $_POST["correo"]; 
$fecha=date("y,m,d");

if ( $_POST[ 'form' ] == "form2"){
if($usuario==NULL|$contrasena==NULL|$contrasenar==NULL|$pais==NULL|$correo==NULL) { 
echo "";
}else{  
if($contrasena!=$contrasenar) { 
echo ""; 
}else{
if ((strlen($correo) <= 6) or (substr_count($correo,"@") != 1) or (substr($correo,0,1) == "@") or (substr($correo,strlen($correo)-1,1) == "@") or (strstr($correo,"'")) or (strstr($correo,"\"")) or (strstr($correo,"\\")) or (strstr($correo,"\$")) or (strstr($correo," "))){
echo "";
}else{
$checkuser = mysql_query("SELECT usuario FROM usuarios WHERE usuario='$usuario'");
$username_exist = mysql_num_rows($checkuser); 

$checkemail = mysql_query("SELECT correo FROM usuarios WHERE correo='$correo'"); 
$email_exist = mysql_num_rows($checkemail); 

if ($email_exist>0|$username_exist>0) { 
echo ""; 
}else{ 
$query = "INSERT INTO usuarios (usuario, contrasena, pais, correo, fecha) VALUES('$usuario','$contrasena','$pais','$correo','$fecha')";
 mysql_query($query) or die(mysql_error()); 
echo "El usuario $usuario ha sido registrado de manera satisfactoria.";
} 
} 
} 
}
}  
}
?>
		<form method="post" name="formulario">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="50" colspan="2"><table width="100%" height="75" border="0" align="left" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="25" align="left" valign="top"><img src="Imagenes/fonubiI.jpg" width="25" height="75"></td>
                  <td align="left" valign="top" background="Imagenes/fonubiC.jpg"><div align="center" class="UbicacionDePagina">
                    <p>Bienvenidos a la secci&oacute;n de registro de usuario</p>
                    <p class="style11">Ingrese todos sus datos reales y no deje campos vacios para que se realice el registro de manera correcta. </p>
                  </div></td>
                  <td width="25" align="left" valign="top"><img src="Imagenes/fonubiD.jpg" width="25" height="75"></td>
                </tr>
              </table>                              </tr>
            <tr>
              <td height="25" colspan="2">                          </tr>
            <tr>
              <td height="50">
            <label for="textfield"></label><p>
              <label><span class="Texto">Nombre de usuario: </span><br>
              <input name="usuario" type="text" class="Texto" id="usuario" value="<?php if (isset($_POST["usuario"])) {$usuario = $_POST["usuario"]; echo $usuario;} ?>" maxlength="20"/>
              </label>
            </p>
              <td width="700" align="left" valign="baseline">
			  <?php
			  if (isset($_POST["usuario"])) { 
			  $usuario = $_POST["usuario"];
              if($usuario==NULL) { 
			  ?>
			  <p>
			  <table width="300" border="0" align="left" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="25"><img src="Imagenes/error1.png" width="25" height="40"></td>
                  <td background="Imagenes/error2.png"><div align="center" class="style12">Aviso: El campo usuario est&aacute; vacio.</div></td>
                  <td width="25"><img src="Imagenes/error3.png" width="25" height="40"></td>
                </tr>
              </table>
              </p>
			  <?php
              }
			  $checkuser = mysql_query("SELECT usuario FROM usuarios WHERE usuario='$usuario'");
              $username_exist = mysql_num_rows($checkuser); 
			  if ($username_exist>0) { 
			  ?>
			  <p>
              <table width="350" border="0" align="left" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="25"><img src="Imagenes/error1.png" width="25" height="40"></td>
                  <td background="Imagenes/error2.png"><div align="center" class="style12">Aviso: El  nombre de usuario ya est&aacute; en uso.</div></td>
                  <td width="25"><img src="Imagenes/error3.png" width="25" height="40"></td>
                </tr>
              </table>
			  </p>
			  <?php
			  }
              }
              ?>            
              <label><span class="Texto">Correo electrónico:</span><br>
              <input name="correo" type="text" class="Texto" id="correo" value="<?php if (isset($_POST["usuario"])) {$correo = $_POST["correo"]; echo $correo;} ?>" maxlength="40"/>
              </label>
            </p>            </td>
              <td width="700" align="left" valign="baseline">
			  <?php
			  if (isset($_POST["usuario"])) { 
			  $correo = $_POST["correo"];
			  if ((strlen($correo) <= 6) or (substr_count($correo,"@") != 1) or (substr($correo,0,1) == "@") or (substr($correo,strlen(              $correo)-1,1) == "@") or (strstr($correo,"'")) or (strstr($correo,"\"")) or (strstr($correo,"\\")) or (strstr($correo,"\$")) or (strstr($correo," "))){
			  ?>
			  <p>
              <table width="475" border="0" align="left" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="25"><img src="Imagenes/error1.png" width="25" height="40"></td>
                  <td background="Imagenes/error2.png"><div align="center" class="style12">Aviso: El  campo de correo electr&oacute;nico est&aacute; vac&iacute;o o no es v&aacute;lido.</div></td>
                  <td width="25"><img src="Imagenes/error3.png" width="25" height="40"></td>
                </tr>
              </table> 
			  </p>
			  <?php
              }
			  $checkemail = mysql_query("SELECT correo FROM usuarios WHERE correo='$correo'"); 
              $email_exist = mysql_num_rows($checkemail); 
			  if ($email_exist>0) { 
			  ?>
			  <p>
              <table width="525" border="0" align="left" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="25"><img src="Imagenes/error1.png" width="25" height="40"></td>
                  <td background="Imagenes/error2.png"><div align="center" class="style12">Aviso: La  direcci&oacute;n de correo electr&oacute;nico ya se encuentra registrada.</div></td>
                  <td width="25"><img src="Imagenes/error3.png" width="25" height="40"></td>
                </tr>
              </table>
			  </p>
			  <?php
			  }
              }
              ?>			  </td>
            </tr>
                      </table>
          </form>