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

la url del action del formulario parece que la tienes mal puesta , tu mandas los datos del formulario a la misma pagina no??

pues añadimos una linea y veamos que sucede modificamos la linea 12

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. $query="SELECT rut_c, fecha, id_orden_pedido
  45.        FROM orden_pedido";
  46. $query2 = "INSERT INTO `empleado` (`rut_c`, `nombre`, `apellido`, `calle_nro`, `comuna`, `region`) VALUES ('$rut_c','$nombre','$apellido','$calle_nro','$comuna','$region')";
  47. $registro=mysql_query($query2);
  48.  
  49. echo "Historial de ordenes de pedido hechas por clientes:";
  50.  
  51. $result=mysql_query($query);
  52.  
  53. }
  54. ?>
  55.  
  56. </body>
  57. </html>