Foros del Web » Programando para Internet » PHP »

evaluar un valor de un input de tipo text

Estas en el tema de evaluar un valor de un input de tipo text en el foro de PHP en Foros del Web. Me gustaria saber como puedo evaluar un valor de un input de tipo text con mi BD en mysql. QUE AL COLOCAR EN EL INPUT ...
  #1 (permalink)  
Antiguo 27/05/2008, 14:13
Iom
 
Fecha de Ingreso: abril-2008
Mensajes: 47
Antigüedad: 16 años
Puntos: 2
evaluar un valor de un input de tipo text

Me gustaria saber como puedo evaluar un valor de un input de tipo text con mi BD en mysql.

QUE AL COLOCAR EN EL INPUT "1" Y LO ENVIE, VERIFIQUE EN MI BD SI ESTA O NO EN ELLA... ES TODO. MUCHAS GRACIAS AUQUE NO SE SI VA EN PHP O MYSQL YA QUE MI BD ES EN MYSQL
  #2 (permalink)  
Antiguo 27/05/2008, 14:38
Avatar de stramin  
Fecha de Ingreso: marzo-2008
Ubicación: Cubil felino
Mensajes: 1.652
Antigüedad: 16 años, 1 mes
Puntos: 336
Respuesta: evaluar un valor de un input de tipo text

.__.

la envias y preguntas si esta xD

algo asi:

Código PHP:
<?php
if($variab=$_POST['txtvar']){
    
$cnx=mysql_connect("localhost""root""");
    
mysql_select_db("TU BasedeDatos" ,$cnx);
    
$existe=mysql_query("SELECT variab FROM tabla WHERE variab='$variab';" ,$cnx):
    if(
mysql_fetch_array($existe)){
        echo 
"EXISTE";
    }else{
        echo 
"NO EXISTE";
    }
}
?>
<form name="form1" method="post" action="">
variuable:    <input name="txtvar" type="text" id="txtvar">
<input name="submit" type="submit" id="submit" value="Aceptar">
</form>
creo que no falta nada...
  #3 (permalink)  
Antiguo 27/05/2008, 19:23
Avatar de argy  
Fecha de Ingreso: octubre-2007
Ubicación: Longitud 75º Latitud 18º Sur
Mensajes: 614
Antigüedad: 16 años, 5 meses
Puntos: 18
Respuesta: evaluar un valor de un input de tipo text

si parece que esta bien , yo le agregaria un empty
asi

if(empty(mysql_fetch_array($existe))){
echo "EXISTE";
}else{
echo "NO EXISTE";
}
ademas en la consulta debe de haber u poco de seguridad como este

$variab=mysql_real_escape_string($variab);
sprintf("SELECT variab FROM tabla WHERE variab='%s';",$variab)
  #4 (permalink)  
Antiguo 27/05/2008, 19:26
Avatar de jam1138
/** @package Moderador */
 
Fecha de Ingreso: julio-2004
Ubicación: sèveR led onieR lE
Mensajes: 9.368
Antigüedad: 19 años, 8 meses
Puntos: 102
Respuesta: evaluar un valor de un input de tipo text

Sugiero utilizar mejor mysql_num_rows() y se tendría mayor información.

__________________
٩(͡๏̯͡๏)۶
» Cómo hacer preguntas de manera inteligente «

"100 años después, la revolución no es con armas, es intelectual y digital"
  #5 (permalink)  
Antiguo 28/05/2008, 06:49
Iom
 
Fecha de Ingreso: abril-2008
Mensajes: 47
Antigüedad: 16 años
Puntos: 2
Respuesta: evaluar un valor de un input de tipo text

BUENO LE COMENTO QUE ME FUNCIONA MUY BIEN COMO ME DIC STRAMIN AUNQUE COLOQUE EL EMPTY QUE ME SIGUIRIO ARGY PERO NO ME FUNCIONO!!. Y TAMBIEN FUNCIONA BIEN CON EL mysql_num_rows() QUE DIC JAM1138..... MUCHAS GRACIAS A TODOS :)
  #6 (permalink)  
Antiguo 28/05/2008, 09:32
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: evaluar un valor de un input de tipo text

Hola Iom,

Te recomiendo no uses mayúsculas para tus mensajes, ya que se considera que estás gritando.

Saludos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 00:21.