Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/03/2014, 21:59
keivis
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
sos con registro a base de datos no registra

Hola saludos nuevamente en este maravilloso foro en busca de un poco de ayuda, mi problema es el siguiente tengo un formulario el cual no me registra en la bd. por espero me puedan ayudar a corregir el error.

aqui el codigo

Código PHP:
Ver original
  1. <?php
  2.  
  3. <body>
  4. <?php
  5. include ("config.php");
  6. $con=mysql_connect($host,$user,$pass);
  7. if (!$con) {
  8. die('Problemas con el servidor: ' . mysql_error());
  9. }
  10. $db_selected = mysql_select_db($db,$con);
  11. if (!$db_selected) {
  12. die ('Error al conectar a la BD. : ' . mysql_error());
  13. }
  14. if (isset($_POST['guardar'])) {
  15.  
  16. $post_ano = $_POST['ano'];
  17. $post_numero = $_POST['numero'];
  18. $post_folio = $_POST['folio'];
  19. $post_fecha = $_POST['fecha'];
  20.  
  21. $post_aut = $_POST['nombre_aut'];
  22. $post_cargo = $_POST['cargo'];
  23. $post_cedula_aut = $_POST['cedula_aut'];
  24.  
  25. $post_nombre_nino = strtoupper($_POST['nombre_nino']);
  26. $post_sexo = $_POST['sexo'];
  27. $post_dia = $_POST['dia'];
  28. $post_mes = $_POST['mes'];
  29. $post_year = $_POST['year'];
  30. $post_nacido = strtoupper($_POST['nacido']);
  31. $post_hora = $_POST['hora'];
  32. $post_minutos = $_POST['minutos'];
  33. $post_am_pm = $_POST['am_pm'];
  34. $post_lugar_nino = strtoupper($_POST['lugar_nino']);
  35. $post_municipio_nino = strtoupper($_POST['municipio_nino']);
  36. $post_estado_nino = strtoupper($_POST['estado_nino']);
  37. $post_legitimo = strtoupper($_POST['legitimo']);
  38.  
  39. $post_nombre_testigo1 = strtoupper($_POST['nombre_testigo1']);
  40. $post_cedula_testigo1 = $_POST['cedula_testigo1'];
  41. $post_nombre_testigo2 = strtoupper($_POST['nombre_testigo2']);
  42. $post_cedula_testigo2 = $_POST['cedula_testigo2'];
  43.  
  44. $post_nombre_madre = strtoupper($_POST['nombre_madre']);
  45. $post_cedula_madre = $_POST['cedula_madre'];
  46. $post_edad_madre = $_POST['edad_madre'];
  47. $post_nacionalidad_madre = $_POST['nacionalidad_madre'];
  48. $post_civil_madre = $_POST['civil_madre'];
  49. $post_prof_madre = strtoupper($_POST['prof_madre']);
  50. $post_domicilio_madre = strtoupper($_POST['domicilio_madre']);
  51. $post_lugar_madre = strtoupper($_POST['lugar_madre']);
  52. $post_municipio_madre = strtoupper($_POST['municipio_madre']);
  53. $post_estado_madre = strtoupper($_POST['estado_madre']);
  54.  
  55. $post_nombre_padre = strtoupper($_POST['nombre_padre']);
  56. $post_cedula_padre = $_POST['cedula_padre'];
  57. $post_edad_padre = $_POST['edad_padre'];
  58. $post_nacionalidad_padre = $_POST['nacionalidad_padre'];
  59. $post_civil_padre = $_POST['civil_padre'];
  60. $post_prof_padre = strtoupper($_POST['prof_padre']);
  61. $post_domicilio_padre = strtoupper($_POST['domicilio_padre']);
  62. $post_lugar_padre = strtoupper($_POST['lugar_padre']);
  63. $post_municipio_padre = strtoupper($_POST['municipio_padre']);
  64. $post_estado_padre = strtoupper($_POST['estado_padre']);
  65.  
  66. $post_nombre_otro = strtoupper($_POST['nombre_otro']);
  67. $post_cedula_otro = $_POST['cedula_otro'];
  68. $post_edad_otro = $_POST['edad_otro'];
  69. $post_nacionalidad_otro = $_POST['nacionalidad_otro'];
  70. $post_civil_otro = $_POST['civil_otro'];
  71. $post_prof_otro = strtoupper($_POST['prof_otro']);
  72. $post_parentesco = strtoupper($_POST['parentesco']);
  73. $post_domicilio_otro = strtoupper($_POST['domicilio_otro']);
  74. $post_lugar_otro = strtoupper($_POST['lugar_otro']);
  75. $post_municipio_otro = strtoupper($_POST['municipio_otro']);
  76. $post_estado_otro = strtoupper($_POST['estado_otro']);
  77.  
  78. $post_usuario = $_SESSION['username'];
  79.  
  80.  
  81. $post_presentacion = $_POST['rad_presentacion'];
  82. if ($post_presentacion == 'rad_padre') {
  83.  $post_pre_padre = 1;
  84.  $post_pre_madre = 0;
  85.  $post_pre_otro = 0;
  86. }
  87.  
  88. if ($post_presentacion == 'rad_madre') {
  89.  $post_pre_padre = 0;
  90.  $post_pre_madre = 1;
  91.  $post_pre_otro = 0;
  92. }
  93.  
  94. if ($post_presentacion == 'rad_otro') {
  95.  $post_pre_padre = 0;
  96.  $post_pre_madre = 0;
  97.  $post_pre_otro = 1;
  98. }
  99.  
  100. $post_op_marginal = $_POST['rad_marginal'];
  101. $post_nota_marginal = strtoupper($_POST['nota_marginal']);
  102. if ($post_op_marginal == 'nota_si') {
  103.  $post_op_marginal_t = "SI";
  104. }
  105. if ($post_op_marginal == 'nota_no') {
  106.  $post_op_marginal_t = "NO";
  107. }
  108.  
  109. if ($post_am_pm == 'AM'){
  110.    $post_am_pm_t = 1;
  111. }
  112. if ($post_am_pm == 'PM'){
  113.    $post_am_pm_t = 2;
  114. }
  115. list($diax,$mesx,$aniox)=explode("-",$post_fecha);
  116. $post_fecha_t = "$aniox-$mesx-$diax";
  117.  
  118. $post_fecha_nac = "$post_year-$post_mes-$post_dia";
  119.  
  120. if ($post_sexo=="MASCULINO") {
  121.     $post_sexo_t = 1;
  122.     } else {
  123.     $post_sexo_t = 2;
  124. }
  125.  
  126. if ($_POST['ano'] <> "" and $_POST['numero'] <> "" and $_POST['folio'] <> "" and $_POST['fecha'] <> "" and $_POST['nombre_nino'] <> "" and $_POST['sexo'] <> "" and $_POST['dia'] <> "" and $_POST['mes'] <> "" and $_POST['year'] <> "" and $_POST['nacido'] <> "" and $_POST['hora'] <> "" and $_POST['minutos'] <> "" and $_POST['am_pm'] <> "" and $_POST['lugar_nino'] <> "" and $_POST['municipio_nino'] <> "" and $_POST['estado_nino'] <> "" and $_POST['nombre_testigo1'] <> "" and $_POST['cedula_testigo1'] <> "" and $_POST['nombre_testigo2'] <> "" and $_POST['cedula_testigo2'] <> "" and $_POST['nombre_madre'] <> "" and $_POST['cedula_madre'] <> "" and $_POST['edad_madre'] <> "" and $_POST['nacionalidad_madre'] <> "" and $_POST['civil_madre'] <> "" and $_POST['prof_madre'] <> "" and $_POST['domicilio_madre'] <> "" and $_POST['lugar_madre'] <> "" and $_POST['municipio_madre'] <> "" and $_POST['estado_madre'] <> "" and $_POST['nombre_padre'] <> "" and $_POST['cedula_padre'] <> "" and $_POST['edad_padre'] <> "" and $_POST['nacionalidad_padre'] <> "" and $_POST['civil_padre'] <> "" and $_POST['prof_padre'] <> "" and $_POST['domicilio_padre'] <> "" and $_POST['lugar_padre'] <> "" and $_POST['municipio_padre'] <> "" and $_POST['estado_padre'] <> "" and $_POST['rad_presentacion'] <> "" and $_POST['nombre_otro'] <> "" and $_POST['cedula_otro'] <> "" and $_POST['edad_otro'] <> "" and $_POST['nacionalidad_otro'] <> "" and $_POST['civil_otro'] <> "" and $_POST['prof_otro'] <> "" and $_POST['parentesco'] <> "" and $_POST['domicilio_otro'] <> "" and $_POST['lugar_otro'] <> "" and $_POST['municipio_otro'] <> "" and $_POST['estado_otro'] <> "" and $_POST['nota_marginal'] <> "") {
  127.  
  128.  
  129. $consulta="insert into nacimientos values('$post_ano','$post_numero','$post_fecha_t','$post_folio','$post_aut','$post_cargo','$post_cedula_aut','$post_nombre_madre',$post_edad_madre,'$post_nacionalidad_madre','$post_civil_madre','$post_cedula_madre','$post_prof_madre','$post_domicilio_madre','$post_lugar_madre','$post_municipio_madre','$post_estado_madre','$post_pre_madre','$post_nombre_padre','$post_edad_padre','$post_nacionalidad_padre','$post_civil_padre','$post_cedula_padre','$post_prof_padre','$post_domicilio_padre','$post_lugar_padre','$post_municipio_padre','$post_estado_padre','$post_pre_padre','$post_nombre_nino','$post_sexo_t','$post_fecha_nac','$post_nacido','$post_hora,$post_minutos','$post_am_pm_t','$post_lugar_nino','$post_municipio_nino','$post_estado_nino','$post_legitimo','$post_cedula_testigo1,'$post_nombre_testigo1','$post_cedula_testigo2','$post_nombre_testigo2','$post_nombre_otro','$post_cedula_otro','$post_edad_otro','$post_nacionalidad_otro','$post_civil_otro','$post_prof_otro','$post_parentesco','$post_domicilio_otro','$post_lugar_otro','$post_municipio_otro','$post_estado_otro','$post_op_marginal_t','$post_nota_marginal','$post_usuario');";
  130. $query = mysql_query($consulta); mysql_close($con); }}?>
  131. <form action="registrar_nacimiento.php" name="formul" method="post">
  132.  
  133. <?php
  134. $fecha_reg = date("d-m-Y");
  135. $anio_reg = date("Y");
  136. ?>

aqui la tabla de la bd

Código SQL:
Ver original
  1. --
  2.  
  3.  
  4. CREATE TABLE IF NOT EXISTS `nacimientos` (
  5.   `ano` INT(11) NOT NULL,
  6.   `numero` INT(11) NOT NULL,
  7.   `fecha` DATE NOT NULL,
  8.   `folio` VARCHAR(20) NOT NULL,
  9.   `autoridad` VARCHAR(60) NOT NULL,
  10.   `cargo_autoridad` VARCHAR(60) NOT NULL,
  11.   `cedula_autoridad` INT(11) NOT NULL,
  12.   `nombre_madre` VARCHAR(60) NOT NULL,
  13.   `edad_madre` INT(11) NOT NULL,
  14.   `nacionalidad_madre` VARCHAR(20) NOT NULL,
  15.   `civil_madre` VARCHAR(15) NOT NULL,
  16.   `cedula_madre` INT(11) NOT NULL,
  17.   `prof_madre` VARCHAR(100) NOT NULL,
  18.   `domicilio_madre` VARCHAR(300) NOT NULL,
  19.   `ciudad_madre` VARCHAR(30) NOT NULL,
  20.   `municipio_madre` VARCHAR(20) NOT NULL,
  21.   `estado_madre` VARCHAR(20) NOT NULL,
  22.   `presenta_madre` INT(11) NOT NULL,
  23.   `nombre_padre` VARCHAR(60) NOT NULL,
  24.   `edad_padre` INT(11) NOT NULL,
  25.   `nacionalidad_padre` VARCHAR(20) NOT NULL,
  26.   `civil_padre` VARCHAR(15) NOT NULL,
  27.   `cedula_padre` INT(11) NOT NULL,
  28.   `prof_padre` VARCHAR(100) NOT NULL,
  29.   `domicilio_padre` VARCHAR(300) NOT NULL,
  30.   `ciudad_padre` VARCHAR(30) NOT NULL,
  31.   `municipio_padre` VARCHAR(20) NOT NULL,
  32.   `estado_padre` VARCHAR(20) NOT NULL,
  33.   `presenta_padre` INT(11) NOT NULL,
  34.   `nombre_nino` VARCHAR(60) NOT NULL,
  35.   `sexo_nino` INT(11) NOT NULL,
  36.   `fecha_nino` DATE NOT NULL,
  37.   `hospital` VARCHAR(100) NOT NULL,
  38.   `hora` INT(11) NOT NULL,
  39.   `minuto` INT(11) NOT NULL,
  40.   `am_pm` INT(11) NOT NULL,
  41.   `ciudad_nino` VARCHAR(30) NOT NULL,
  42.   `municipio_nino` VARCHAR(20) NOT NULL,
  43.   `estado_nino` VARCHAR(20) NOT NULL,
  44.   `legitimo` VARCHAR(2) NOT NULL,
  45.   `cedula_testigo1` INT(11) NOT NULL,
  46.   `nombre_testigo1` VARCHAR(60) NOT NULL,
  47.   `cedula_testigo2` INT(11) NOT NULL,
  48.   `nombre_testigo2` VARCHAR(60) NOT NULL,
  49.   `nombre_otro` VARCHAR(60) NOT NULL,
  50.   `cedula_otro` INT(11) NOT NULL,
  51.   `edad_otro` INT(11) NOT NULL,
  52.   `nacionalidad_otro` VARCHAR(20) NOT NULL,
  53.   `civil_otro` VARCHAR(15) NOT NULL,
  54.   `prof_otro` VARCHAR(100) NOT NULL,
  55.   `parentesco` VARCHAR(30) NOT NULL,
  56.   `domicilio_otro` VARCHAR(200) NOT NULL,
  57.   `ciudad_otro` VARCHAR(30) NOT NULL,
  58.   `municipio_otro` VARCHAR(20) NOT NULL,
  59.   `estado_otro` VARCHAR(20) NOT NULL,
  60.   `op_marginal` VARCHAR(2) NOT NULL,
  61.   `nota_marginal` text NOT NULL,
  62.   `usuario` VARCHAR(20) NOT NULL

de ante mano gracias por su ayuda..