Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/04/2014, 20:55
darkcl0wn
 
Fecha de Ingreso: febrero-2014
Mensajes: 32
Antigüedad: 10 años, 3 meses
Puntos: 0
Buscar en bd mysql y mostrar datos

Hola, hace poco empece a estudiar lo que es Php y base de datos mysql y lo que quiero hacer es que, al buscar algo en un input html por ejemplo "Pepe" Me aparezca el apellido por ejemplo en otro input, estoy muy mareado con esto aqui mi codigo que no funciona.

Código PHP:
Ver original
  1. <?php include('conexion.php'); ?> //Incluye mi archivo de conexion a la base de datos
  2. <?php
  3. $var2="";
  4. $btn=$_POST["btn1"];
  5. $bus=$_POST["txtbus"];
  6.  
  7. if($btn=="Buscar"){
  8.  
  9. $sql="select * from usuarios where usuario_email='$bus'";
  10. $cs=mysql_query($sql,$cn);
  11. while($resul=mysql_fetch_array($cs)){
  12. $var2=$resul[0];
  13. }
  14. }
  15. ?>

Código HTML:
Ver original
  1. <!doctype html>
  2. <meta charset="utf-8">
  3. <title>Documento sin título</title>
  4. </head>
  5. <form action="" method="post" name="form">
  6. <p>
  7. <input type="text" name="txtbus" id="txtbus">
  8. <input type="submit" name="btn1" id="btn1">
  9. </p>
  10. <p>
  11. <input type="text" name="txttel" value="<?php echo $var2?>"/>
  12. </p>
  13. </form>
  14.  
  15. </body>
  16. </html>