Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/03/2017, 23:46
Avatar de aviweb2015
aviweb2015
 
Fecha de Ingreso: abril-2016
Ubicación: venezuela
Mensajes: 215
Antigüedad: 8 años
Puntos: 1
no se guardar los datos pdo

saludo comunidad estoy tratando de guardar un registro pero no logro guardar y aparte de eso tengo otro problema:

1- consulto mis datos y todo bien que serian los datos personales del paciente, luego en esa misma consulta, consulto una tabla donde voy agregar los exámenes al paciente, pero cuando le doy al botón para guardar se pierden los datos y como lo mencionado anterior mente no me guardar anexo los códigos.



proceso para registrar


Código PHP:
Ver original
  1. <!-- proceso para registrar-->
  2.  
  3. <?php
  4.  
  5.  
  6. if(isset($_POST['guardar'])){
  7.   $sql = "SELECT id FROM examenes_laboratorio_pacientes WHERE id = :id LIMIT 1"; //Creamos la select
  8.   $check = $DB_con->prepare($sql); //Preparamos la SELECT, de ésta manera evitamos SQL Injection
  9.   $check->bindParam(':id', $_POST['id']);//Substituimos las variables de la SELECT
  10.   $check->execute();//Ejecutamos la consulta
  11.   $contador = $check -> rowCount();//Esta función devuelve el número de resultados que ha devuelto la SELECT
  12.   if ($contador > 0) {
  13.   $check->closeCursor();
  14.    
  15. $mensaje = "<div class='col s12 card-panel blue lighten-2 center'>
  16. <h5 class='black-text text-darken-2 center CONDENSED LIGHT5'>
  17. ¡ Ups Aviso: El Registro ya se Encuentra Insertado !
  18. </h5>
  19. </div>";
  20. header("refresh:5;examenes_laboratorio.php");
  21.  
  22.  
  23. $sql = false;
  24.  
  25.  
  26.     }
  27.     else
  28.     {
  29.  
  30.  
  31. for ($i = 0; $i < count($fk_examen_laboratorio); $i++) {
  32.  
  33.  
  34. $sql=$DB_con->prepare("INSERT INTO examenes_laboratorio_pacientes (id,fk_cedula,fk_examen_laboratorio,fecha)
  35.  VALUES (:id, :fk_cedula, :$fk_examen_laboratorio[$i], :fecha)");
  36. $sql->bindParam(':id',$_POST['id']);
  37. $sql->bindParam(':fk_cedula',$_POST['fk_cedula']);
  38. $sql->bindParam(':id',$_POST['fk_examen_laboratorio']);
  39. $sql->bindParam(':fecha',$_POST['fecha']);
  40. $sql->execute();
  41.  
  42.        }
  43.  
  44.    }
  45.  
  46.  
  47. if($sql)
  48.  
  49. {
  50.  
  51. $mensaje ="<div class='col s12 card-panel teal lighten-2 center'>
  52. <h5 class='black-text text-darken-2 center CONDENSED LIGHT5'>
  53. ¡ Bien Hecho: Registro Insertado Correctamente !
  54. </h5>
  55. </div>";
  56. header("refresh:5;examenes_laboratorio.php");
  57.  
  58.      }
  59.  
  60. }
  61.  
  62. ?>
  63. <!-- fin proceso para registrar-->




formulario para el registro

Código PHP:
Ver original
  1. <!-- formulario de registro-->
  2.  
  3.  
  4. <div class="row">
  5.  
  6. <?php
  7. $id= $_GET['id'];
  8. $consulta = $DB_con->prepare("SELECT * FROM historia_clinica WHERE id=:id");
  9. $consulta->execute(array(':id'=>$id));
  10. $editar_linea = $consulta->fetch(PDO::FETCH_ASSOC);{
  11. //extract($editar_linea);
  12. extract((array)$editar_linea);
  13. ?>
  14.  
  15.  
  16. <form class='col s12' action='examenes_laboratorio.php' name='frmContacto' method='POST'>
  17.  
  18.  
  19. <?php echo $mensaje; ?>
  20.  
  21. <h5 class='left-align black-text thin'>
  22. <span class='white-text'>Paciente:</span>&nbsp;<?php echo $editar_linea['nombres']; ?>&nbsp;
  23. <?php echo $editar_linea['apellidos']; ?>&nbsp;&nbsp;
  24. <span class='white-text'>Cédula:</span>&nbsp;<?php echo $editar_linea['cedula']; ?>&nbsp;
  25. <span class='white-text'>Edad:</span>&nbsp;<?php echo $editar_linea['edad']; ?>&nbsp;
  26. <span class='white-text'>E-Mail:</span>&nbsp;<?php echo $editar_linea['email']; ?>
  27. <br>
  28. <span class='white-text'>Fecha Historia Clinica:</span>&nbsp;<?php echo $editar_linea['fecha_creacion_historia_clinica']; ?>
  29. &nbsp;
  30. <span class='white-text'>N° Historia Clinica:</span>&nbsp;<?php echo $editar_linea['id']; ?>
  31.  
  32. </h5>
  33.  
  34. <hr>
  35.  
  36. <h4 class='center-align black-text thin'>Examen Laboratorio</h4>
  37.  
  38.  
  39.  
  40. <div class='row' style='max-width: 600px;'>
  41. <div class='card-panel white lighten-1 col s12'>
  42. <img src='../img cintillo/cintillo.png' class='responsive-img rectangule'>
  43. <hr>
  44. <br>
  45. <div class='col s12'>
  46. <span>Pac:</span>&nbsp;<?php echo $editar_linea['nombres']; ?>&nbsp;<?php echo $editar_linea['apellidos']; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>Edad:</span>&nbsp;<?php echo $editar_linea['edad']; ?>
  47. <br>
  48.  
  49. <?php
  50.  
  51. }
  52.  
  53. ?>
  54.  
  55. <span>Fecha:</span>&nbsp;<?php echo date('d/m/Y');?>
  56. <br>
  57. <h5 class='center-align thin'>Examen Laboratorio</h5>
  58.  
  59. </br>
  60.  
  61.  
  62. <?php
  63. $consulta = $DB_con->query("SELECT * FROM examen_laboratorio ORDER BY id");
  64. while ($linea = $consulta->fetch(PDO::FETCH_ASSOC)) {
  65.  
  66. echo "<p>";
  67. echo "<input type='checkbox' name='fk_examen_laboratorio[]' id='chk1{$linea['id']}' value='{$linea['id']}' />";
  68. echo "<label class='black-text' for='chk1{$linea['id']}'>*&nbsp;{$linea['examen']}:&nbsp;&nbsp;{$linea['descripcion']}</label>";
  69. echo "</p>";
  70.  
  71. }
  72. ?>
  73.  
  74. OTROS:_________________________________________________________
  75.               _______________________________________________________________
  76.  
  77.  
  78.  
  79.  
  80. <div class="center-align">
  81.  
  82. <br><br>
  83.  
  84.  
  85.  
  86.  
  87. </div>
  88.  
  89.  
  90. </div>
  91.  
  92.  
  93.  
  94. </div>
  95.  
  96.  
  97.  
  98. </div>
  99.  
  100. <br>
  101. <div class='center-align'>
  102.  
  103.  
  104. <button class='btn waves-effect blue-grey darken-4 btn-medium' data-position='bottom' type='submit' name='guardar'>Agregar Examen Laboratorio</button>
  105.  
  106. <button class='btn waves-effect blue-grey darken-4 btn-medium' data-position='bottom'
  107.  type='reset' name='borrar'>Borrar</button>
  108.  
  109. <a href='javascript:history.back(1)' class='btn waves-effect blue-grey darken-4 btn-medium'>Volver</a>
  110.  
  111.  
  112. </div>
  113. <input type='hidden' name='id' value='<?php echo $id; ?>'>
  114. <input type='hidden' name='fk_cedula' value='<?php echo $cedula; ?>'>
  115. <input type='hidden' name='fecha' value='<?php echo date('d/m/Y');?>'>
  116. </form>
  117.  
  118.  
  119. <!-- FIN formulario-->



los errores que me dan son esto


Cita:
Notice: Undefined variable: fk_examen_laboratorio in C:\xampp\htdocs\umom\admin\examenes_laboratorio.ph p on line 52

que seria la linea del: for ($i = 0; $i < count($fk_examen_laboratorio); $i++) {

y el otro error que meda es este: Notice: Undefined index: id in C:\xampp\htdocs\umom\admin\examenes_laboratorio.ph p on line 137

que seria la linea del: $id= $_GET['id'];
cuando se consulta muestra los datos perfectamente

Cita:
Paciente: yoclens avilan Cédula: 14622737 Edad: 30 E-Mail: [email protected]
Fecha Historia Clinica: 06/02/2017 N° Historia Clinica: 5
pero luego de dar al boton guadar se pierden los datos

Cita:
Paciente: Cédula: Edad: E-Mail:
Fecha Historia Clinica: N° Historia Clinica:

gracias de ante mano
__________________
yoclens avilan

Última edición por aviweb2015; 02/03/2017 a las 23:50 Razón: me falto algo