Ver Mensaje Individual
  #11 (permalink)  
Antiguo 09/06/2012, 16:27
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Error al conectar PHP con BBDD

segun como lo tienes los datos se guardan en la tabala empleado , la consulta que esta de mas es la de $query que es la que haces un select , pero que en realidad no te sirve de nada

prueba asi y me comentas los cambios que hecho son en la linea 46 he concatenado las variables

Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8.  
  9.  
  10. <body>
  11.  
  12. <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
  13. <b>Formulario de registro de Cliente</b> <br><br>
  14.  
  15. Primer nombre: <input type="text" name="nombre"><br>
  16. Primer apellido: <input type="text" name="apellido"><br>
  17. RUT: <input type="text" name="rut_c"><br>
  18. Calle y número: <input type="text" name="calle_nro"><br>
  19. Comuna: <input type="text" name="comuna"><br>
  20. Región: <input type="text" name="region"><br>
  21.  
  22. <input type="submit" value="Registrar">
  23. </form>
  24.  
  25.  
  26.  
  27. <?php
  28.  
  29. if(isset($_POST['nombre'])){
  30.  
  31. $host="localhost";
  32. $username="root";
  33. $password="cocodrilo";
  34. $db="omohr4";
  35.  
  36. $nombre=$_POST['nombre'];
  37. $apellido=$_POST['apellido'];
  38. $rut_c=$_POST['rut_c'];
  39. $calle_nro=$_POST['calle_nro'];
  40. $comuna=$_POST['comuna'];
  41. $region=$_POST['region'];
  42.  
  43. mysql_connect($host,$username,$password);
  44.  
  45. $query = "INSERT INTO `empleado` (`rut_c`, `nombre`, `apellido`, `calle_nro`, `comuna`, `region`) VALUES ('".$rut_c."','".$nombre."','".$apellido."','".$calle_nro."','".$comuna."','".$region."')";
  46. $registro=mysql_query($query);
  47.  
  48. echo "Historial de ordenes de pedido hechas por clientes:";
  49.  
  50.  
  51.  
  52. }
  53. ?>
  54.  
  55. </body>
  56. </html>