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<table class="centrada" border="1" >
<tr>
<td><p><a href=""><img src="disfruta/imagen1.jpg " border="0" width="200" height="80"></a></p></td>
<td><p><a href=""><img src="disfruta/imagen2.jpg " border="0" width="150" height="100"></a></p></td>
</tr>
</table>
<?php
include("../Connections/siatt.php");
include("disfruta2.php"); //ESTE DOCUMENTO TIENE MI INSERT ABAJO LO PONDRE
?>
<body>
<form name="form_hotel" action="formulario.php" method="post">
<table class="centrada" border="1" >
<p>
<?php
$hoteles="SELECT nombre_h FROM siat_hoteles";
?>
<td>Hotel:</td>
<td><select name="hotel_dx" id= "hotel_dx">
<?
echo "<option> Selecciona:</option>";
echo "<option value='".$row['nombre_h']."'>".$row['nombre_h']."</option>";
};
?>
</select>
<input type="submit" name="buscador" value="Buscar" />
<!--</form>
</table>
</body>-->
<?php
if ($_POST['buscador'])
{
$buscar = $_POST['hotel_dx'];
{
echo "No se ha ingresado una cadena a buscar";
}//llave de empty buscar
else{
include("../Connections/siat.php");
$sql = "SELECT * FROM siat_hoteles WHERE nombre_h = '$buscar'";
//$total = mysql_num_rows($result);
echo "<br>Resultados para: ";
if($buscar == $row['nombre_h']){echo $row['nombre_h'];}
do {
?>
<br>hotel:<input type="text" size="30" maxlength="60" value=<?php echo $row['nombre_h'];?> name="hotel_dx"> </a></b></p>
<br>Habitaciones: <input type="text" size="15" maxlength="300" value=<?php echo $row['cuartos_h'];?> name="cuartos_dx"> </a></b></p>
<!--<br>Logotipo: <input type="text" size="15" maxlength="300" value=<?php echo $row['imagen_h'];?> name="cuartos_dx"> </a></b></p>-->
<td class="normal"colspan="5"><img src="imagenes/hoteles/<?php echo $row['imagen_h'];?>" height="100"></a></td>
<tr>
<td>Fecha:</td>
<td><input type="text" size="15" maxlength="30" value="" name="fecha_dx" placeholder="aaaa-mm-dd"></td>
</tr>
<tr>
<td>Ocupación Nacional:</td>
<td><input type="text" size="15" maxlength="30" value="" name="tnac_dx"></td>
</tr>
<tr>
<td>Ocupación Extranjera:</td>
<td><input type="text" size="15" maxlength="30" value="" name="text_dx"></td>
</tr>
<tr>
<td>
<p>
<input type="submit" name="enviar" id="enviar" value="Guardar" />
<!--<input type="button" name="guardar" value="Guardar" onclick="checar()">-->
</p>
<p> </p>
</td>
<td>
<p>
<input type="reset" value="Borrar">
</p>
<p> </p>
</td>
</tr>
<?php
//echo "<p>Resultados: $total</p>";
}
else {
echo "No se encontraron resultados para: <b>$buscar</b>";
}
}
}
?>
</form>
</table>
</body>
EN ESTE OTRO ES DONDE HAGO MI INSERT A LA BASE DE DATOS
disfruta2.php
Código PHP:
Ver original<?php
$hotel_dx = $_POST["hotel_dx"];
$cuartos_dx = $_POST["cuartos_dx"];
$fecha_dx = $_POST["fecha_dx"];
$tnac_dx = $_POST["tnac_dx"];
$text_dx = $_POST["text_dx"];
?>
<?php
include("../Connections/siat.php");
mysql_query("INSERT INTO hoteles_disfruta_pruebas(hotel_dx,cuartos_dx,fecha_dx,tnac_dx,text_dx) values('$hotel_dx','$cuartos_dx','$fecha_dx', '$tnac_dx' , '$text_dx')");
?>