Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/12/2013, 18:52
sahe_lizzy
 
Fecha de Ingreso: noviembre-2013
Ubicación: México
Mensajes: 22
Antigüedad: 11 años, 2 meses
Puntos: 0
Pregunta Como evito que se inserten ceros en mi base de datos cada vez que actualizo mi pagina

Bueno estoy creando un formulario en el cual mediante un option value (combo box) en php pero tengo dos detalles uno que cada que actualizo mi pagina me insertan ceros y el otro son los dos botones que tiene mi formulario ambos mandan información a la base lo cual no debiera pasar les dejo mis dos códigos espero que me puedan apoyar

MI FORMULARIO ES ESTE

Código PHP:
Ver original
  1. <table class="centrada" border="1" >
  2. <tr>
  3. <td><p><a href=""><img src="disfruta/imagen1.jpg " border="0" width="200" height="80"></a></p></td>
  4. <td><p><a href=""><img src="disfruta/imagen2.jpg " border="0" width="150" height="100"></a></p></td>
  5. </tr>
  6. </table>
  7.  
  8. <?php
  9. include("../Connections/siatt.php");
  10. include("disfruta2.php"); //ESTE DOCUMENTO TIENE MI INSERT ABAJO LO PONDRE
  11. ?>
  12.  
  13. <body>
  14. <form name="form_hotel" action="formulario.php" method="post">
  15.  
  16.   <table class="centrada" border="1" >
  17.  <p>
  18.    <?php
  19. $hoteles="SELECT nombre_h FROM siat_hoteles";
  20. $result=mysql_query($hoteles);
  21.  
  22. ?>
  23.  
  24. <td>Hotel:</td>
  25.   <td><select name="hotel_dx" id= "hotel_dx">
  26. <?
  27. echo "<option> Selecciona:</option>";
  28. while($row=mysql_fetch_array($result)){
  29. echo "<option value='".$row['nombre_h']."'>".$row['nombre_h']."</option>";
  30. };
  31. ?>
  32. </select>
  33.  
  34. <input type="submit" name="buscador" value="Buscar" />
  35.  
  36. <!--</form>
  37. </table>
  38. </body>-->
  39.  
  40. <?php
  41. if ($_POST['buscador'])
  42. {
  43. $buscar = $_POST['hotel_dx'];
  44.  
  45. if(empty($buscar))
  46. {
  47. echo "No se ha ingresado una cadena a buscar";
  48. }//llave de empty buscar
  49. else{
  50. include("../Connections/siat.php");
  51. $sql = "SELECT * FROM siat_hoteles WHERE nombre_h = '$buscar'";
  52.  
  53. $result = mysql_query($sql);
  54. //$total = mysql_num_rows($result);
  55. if ($row = mysql_fetch_array($result)){
  56. echo "<br>Resultados para:    ";
  57.  
  58. if($buscar == $row['nombre_h']){echo $row['nombre_h'];}
  59.  
  60. do {
  61. ?>
  62. <br>hotel:<input type="text" size="30" maxlength="60" value=<?php echo $row['nombre_h'];?>  name="hotel_dx"> </a></b></p>
  63. <br>Habitaciones: <input type="text" size="15" maxlength="300" value=<?php echo $row['cuartos_h'];?>  name="cuartos_dx"> </a></b></p>
  64. <!--<br>Logotipo: <input type="text" size="15" maxlength="300" value=<?php echo $row['imagen_h'];?>  name="cuartos_dx"> </a></b></p>-->
  65. <td class="normal"colspan="5"><img src="imagenes/hoteles/<?php echo $row['imagen_h'];?>" height="100"></a></td>
  66.  
  67. <tr>
  68. <td>Fecha:</td>
  69. <td><input type="text" size="15" maxlength="30" value="" name="fecha_dx" placeholder="aaaa-mm-dd"></td>
  70. </tr>
  71. <tr>
  72. <td>Ocupaci&oacute;n Nacional:</td>
  73. <td><input type="text" size="15" maxlength="30" value="" name="tnac_dx"></td>
  74. </tr>
  75. <tr>
  76. <td>Ocupaci&oacute;n Extranjera:</td>
  77. <td><input type="text" size="15" maxlength="30" value="" name="text_dx"></td>
  78. </tr>
  79. <tr>
  80.   <td>
  81.     <p>
  82.  
  83.  
  84.     <input type="submit" name="enviar" id="enviar" value="Guardar" />
  85.     <!--<input type="button" name="guardar" value="Guardar" onclick="checar()">-->
  86.   </p>
  87.   <p>&nbsp;</p>
  88.   </td>
  89.  
  90.     <td>
  91.       <p>
  92.       <input type="reset" value="Borrar">
  93.       </p>
  94.   <p>&nbsp;</p>
  95.   </td>
  96.   </tr>
  97.  
  98.  
  99.  
  100.  
  101. <?php
  102. } while ($row = mysql_fetch_array($result));
  103. //echo "<p>Resultados: $total</p>";
  104. }
  105. else {
  106. echo "No se encontraron resultados para: <b>$buscar</b>";
  107. }
  108. }
  109. }
  110.  
  111. ?>
  112.  
  113. </form>
  114. </table>
  115. </body>

EN ESTE OTRO ES DONDE HAGO MI INSERT A LA BASE DE DATOS
disfruta2.php

Código PHP:
Ver original
  1. <?php
  2.  
  3.     $hotel_dx = $_POST["hotel_dx"];  
  4.     $cuartos_dx = $_POST["cuartos_dx"];  
  5.     $fecha_dx = $_POST["fecha_dx"];  
  6.     $tnac_dx = $_POST["tnac_dx"];  
  7.     $text_dx = $_POST["text_dx"];
  8.  
  9.  
  10.     ?>
  11.  
  12.    
  13. <?php
  14.  
  15.  
  16. include("../Connections/siat.php");  
  17.         mysql_query("INSERT INTO hoteles_disfruta_pruebas(hotel_dx,cuartos_dx,fecha_dx,tnac_dx,text_dx)
  18.        values('$hotel_dx','$cuartos_dx','$fecha_dx', '$tnac_dx' , '$text_dx')");
  19.        
  20.             ?>

Última edición por Triby; 04/12/2013 a las 19:10 Razón: Código en highlight