Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/09/2011, 09:13
johhan16
 
Fecha de Ingreso: junio-2010
Ubicación: Venezuela, Zulia
Mensajes: 686
Antigüedad: 13 años, 10 meses
Puntos: 55
Respuesta: repetición de usuarios

bueno gracias a que no tengo nada que hacer ahorita te ayudare un poco

fijate como quedo aunque pueden haber errores porque no probe nada

formulario.php (la verdad nose como lo llamas tu)

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<
title>Documento sin t&iacute;tulo</title>


<
script src="ajax.js"></script>
</head>

<body>

<form method="post" name="form1" id="form1" action="controlclientes/datoscliente.php"> 
* <table align="center">
* * <tr valign="baseline">
* * * <td nowrap="nowrap" align="right">Tienda:</td>
* * * <td><div id="muestra"><input name="tienda" type="text" id="tienda" value="" size="32" onblur="busca(this.form.tienda.value)" /></div></td>
* * </tr>
* * <tr valign="baseline">
* * * <td nowrap="nowrap" align="right">Email:</td>
* * * <td><input name="email" type="text" id="email" value="" size="32" /></td>
* * </tr>
* * <tr valign="baseline">
* * * <td nowrap="nowrap" align="right">Pasword:</td>
* * * <td><input name="pasword" type="password" id="pasword" value="" size="32" /></td>
* * </tr>
* * <tr valign="baseline">
* * * <td nowrap="nowrap" align="right">Tipo_de_tienda:</td>
* * * <td><input name="tipo_de_tienda" type="text" id="tipo_de_tienda" value="" size="32" /></td>
* * </tr>
* * <tr valign="baseline">
* * * <td nowrap="nowrap" align="right">&nbsp;</td>
* * * <td><input type="submit" onclick="MM_validateForm('tienda','','R','email','','RisEmail','pasword','','R','tipo_de_tienda','','R');return document.MM_returnValue" value="Insertar registro" /></td>
* * </tr>
* </table>
</form>


</body>
</html> 

ajax.js
Código HTML:
function objetoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}


function busca(tienda){

	divResultado = document.getElementById('muestra');
	
		ajax=objetoAjax();

		ajax.open("GET", "buscar.php?tienda="+tienda);
		ajax.onreadystatechange=function() {
			
			if (ajax.readyState==1 || ajax.readyState==2 || ajax.readyState==3) {

				divResultado.innerHTML = "BUSCANDO INFORMACION DE LA TIENDA "+tienda;
				divResultado.style.display="block";

			}
			if (ajax.readyState==4) {
				divResultado.innerHTML = ajax.responseText;
				divResultado.style.display="block";

			}
		}

		ajax.send(null);
}

buscar.php
Código PHP:
<?php
* * 
if (isset(
$_GET['tienda'])) {
*
$tienda $_GET['tienda'];


        *
        
$link mysql_connect("localhost","root","");
        
mysql_select_db("blueberryswebtiendas",$link);
        *
        
        
$sql mysql_query("select count(tienda) as total from tienda where tienda = '$tienda'",$link) or die (mysql_error());
        
$array mysql_fetch_array($sql);
        
        if (
$array['total'] > 0) {
        
        
?>
        <input name="tienda" type="text" id="tienda" value="<?php echo $tienda?>" size="32" onblur="busca(this.form.tienda.value)" />
        <?php echo "Ya existe esta tienda"//aqui despues tu le colocas el diseño que quieras ?>
        <?php 
        
} else {
        
?>
        
        <input name="tienda" type="text" id="tienda" value="<?php echo $tienda?>" size="32" onblur="busca(this.form.tienda.value)" />
        <?php echo "Tienda Nueva"//aqui despues tu le colocas el diseño que quieras ?>
        
        <?php 
        
}
}
*
?>

prueba y me avisas a ver que tal

PostData: No tengo idea de donde salieron esos * yo no los coloque, ni salen en mi codigo
__________________
<?php echo "No te metas a lo hondo del Mar si no sabes nadar, primero aprende a nadar" ?>
...Error en linea: 1 o.O