![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
05/09/2012, 23:07
|
| | Fecha de Ingreso: agosto-2012 Ubicación: Bilbao
Mensajes: 44
Antigüedad: 12 años, 6 meses Puntos: 2 | |
fallo con insert into Hola de nuevo!
Os traigo un nuevo problemilla para ver si me lo podeis resolver.
No se si debería ir aqui o en el foro de mysql pero bueno, supongo que sera un error de php.
Estoy haciendo la web de un hotel y tengo un formulario de reservas tal que:
Código:
<?php
include './includes/headerres.php';
?>
<div class="body">
<script type="text/javascript">
<!--
jQuery(document).ready(function() {
// calendarios
/* Inicialización en español para la extensión 'calendar' para jQuery. */
popUpCal.regional['es'] = {clearText: 'Limpiar', closeText: 'Cerrar',
prevText: '<Ant', nextText: 'Sig>', currentText: 'Hoy',
dayNames: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']};
popUpCal.setDefaults(popUpCal.regional['es']);
popUpCal.setDefaults({autoPopUp: 'both', buttonImageOnly: true,
buttonImage: 'http://www.hotelsanroque.es/imagenes/tarifas-reservas/calendario.gif', buttonText: 'Calendar', showOtherMonths: true});
$('.invokeBoth').calendar({ firstDay: 1 });
// fin calendarios});
});
//-->
function checkDates()
{
if ( $('#fechaentrada').attr("value") == $('#fechasalida').attr("value") )
alert("Las fechas son iguales");
else
{
}
}
</script>
<div style="padding-left:200px;">
<form name="reserva" method="post" onSubmit="return checkbox(this);" action="mail.php" >
<table class="reg">
<tr>
<td><h3 align="center">Reserva de habitacion</h3></td>
</tr>
<tr>
<td class="name">Nombre:</td>
<td class="input"><input type="text" name="nombreres" id="nombreres" /></td>
</tr>
<tr>
<td class="name">Apellidos:</td>
<td class="input"><input type="text" name="apelres" id="apelres" /></td>
</tr>
<tr>
<td class="name">DNI:</td>
<td class="input"><input type="text" name="dni" id="dni" /></td>
</tr>
<tr>
<td class="name">Teléfono móvil:</td>
<td class="input"><input type="text" name="telf" id="telf" /></td>
</tr>
<tr>
<td class"name">Dirección Postal:</td>
<td class="input"><input type="text" name="direc" id="direc" /></td>
</tr>
<tr>
<td class"name">Población:</td>
<td class="input"><input type="text" name="pob" id="pob" /></td>
</tr>
<tr>
<td class"name">Ciudad:</td>
<td class="input"><input type="text" name="ciudad" id="ciudad" /></td>
</tr>
<tr>
<td class"name">Código Postal:</td>
<td class="input"><input type="text" name="codpos" id="codpos" /></td>
</tr>
<tr>
<td class"name">E-Mail:</td>
<td class="input"><input type="text" name="mail" id="mail" /></td>
</tr>
<tr>
<td class="name">Tipo de habitacion:</td>
<td class="input"><SELECT name="habitacion">
<OPTION VALUE="individual">Individual</OPTION>
<OPTION VALUE="doble">Doble</OPTION>
<OPTION VALUE="matrimonio">Matrimonio</OPTION>
<OPTION VALUE="triple">Triple</OPTION>
<OPTION VALUE="cuadruple">Cuadruple</OPTION>
<OPTION VALUE="suite">Suite</OPTION>
</SELECT></td>
</tr>
<tr>
<td class="name">Fecha Entrada:</td>
<td class="input"><input type="text" class="invokeBoth" name="fechaentrada" id="fechaentrada" value="<?=date("d/m/Y");?>" onChange="checkDates();" /></td>
</tr>
<tr>
<td class="name">Fecha Salida:</td>
<td class="input"><input type="text" class="invokeBoth" name="fechasalida" id="fechasalida" value="<?=strftime("%d/%m/%Y", (time() + 24*60*60));?>" onChange="checkDates();" /></td>
</tr>
<tr>
<td class="name">Adultos:</td>
<td class="input"><SELECT name="numadul">
<OPTION VALUE="1">1</OPTION>
<OPTION VALUE="2">2</OPTION>
<OPTION VALUE="3">3</OPTION>
<OPTION VALUE="4">4</OPTION>
<OPTION VALUE="5">5</OPTION>
<OPTION VALUE="6">6</OPTION>
<OPTION VALUE="7">7</OPTION>
<OPTION VALUE="8">8</OPTION>
<OPTION VALUE="9">9</OPTION>
<OPTION VALUE="10">10</OPTION>
</SELECT></td>
</tr>
<tr>
<td class="name">Niños:</td>
<td class="input"><SELECT name="numnino">
<OPTION VALUE="0">0</OPTION>
<OPTION VALUE="1">1</OPTION>
<OPTION VALUE="2">2</OPTION>
<OPTION VALUE="3">3</OPTION>
<OPTION VALUE="4">4</OPTION>
<OPTION VALUE="5">5</OPTION>
<OPTION VALUE="6">6</OPTION>
<OPTION VALUE="7">7</OPTION>
<OPTION VALUE="8">8</OPTION>
<OPTION VALUE="9">9</OPTION>
<OPTION VALUE="10">10</OPTION>
</SELECT>(3-10a)</td>
</tr>
<tr>
<td class="name">Comentarios:</td>
<td class="input"><textarea name="coment" cols="32" rows="6"></textarea></td>
</tr>
<tr>
<td> </br> </td>
</tr>
<tr>
<td class="name"></td>
<td class="input"><input type="submit" name="enviar" value="Enviar" /></td>
</tr>
</table>
</form>
</div>
</div>
<?
include './includes/footer.php';
?>
Y recojo las variables en un php en el cual mando un mail con las varibles y a la vez hago un insert into: Código PHP: <?php
$conexion = mysql_connect("basededatos", "usuario", "password") or die ("No se pudo conectar: " . mysql_error());
mysql_select_db("db427201309") or die ("No se pudo seleccionar la base de datos");
if (!$HTTP_POST_VARS){
$name = (string) $_POST["nombreres"];
$apel = (string) $_POST["apelres"];
$dni = (string) $_POST["dni"];
$telf = (string) $_POST["telf"];
$direc = (string) $_POST["direc"];
$pob = (string) $_POST["pob"];
$ciudad = (string) $_POST["ciudad"];
$codpos = (string) $_POST["codpos"];
$mail = (string) $_POST["mail"];
$habitacion = (string) $_POST["habitacion"];
$fechaentrada = (string) $_POST["fechaentrada"];
$fechasalida = (string) $_POST["fechasalida"];
$numadul = (string) $_POST["numadul"];
$numnino = (string) $_POST["numnino"];
$coment = (string) $_POST["coment"];
} else{
//Estoy recibiendo el formulario, compongo el cuerpo
$cuerpo = "Reserva enviada\n";
$cuerpo .= "Nombre: " . $HTTP_POST_VARS["nombreres"] . "\n";
$cuerpo .= "Apellidos: " . $HTTP_POST_VARS["apelres"] . "\n";
$cuerpo .= "DNI: " . $HTTP_POST_VARS["dni"] . "\n";
$cuerpo .= "Teléfono: " . $HTTP_POST_VARS["telf"] . "\n";
$cuerpo .= "Dirección Postal: " . $HTTP_POST_VARS["direc"] . "\n";
$cuerpo .= "Población: " . $HTTP_POST_VARS["pob"] . "\n";
$cuerpo .= "Ciudad: " . $HTTP_POST_VARS["ciudad"] . "\n";
$cuerpo .= "Código Postal: " . $HTTP_POST_VARS["codpos"] . "\n";
$cuerpo .= "Email: " . $HTTP_POST_VARS["mail"] . "\n";
$cuerpo .= "Tipo de Habitación: " . $HTTP_POST_VARS["habitacion"] . "\n";
$cuerpo .= "Fecha de Entrada: " . $HTTP_POST_VARS["fechaentrada"] . "\n";
$cuerpo .= "Fecha de Salida: " . $HTTP_POST_VARS["fechasalida"] . "\n";
$cuerpo .= "Número de Adultos: " . $HTTP_POST_VARS["numadul"] . "\n";
$cuerpo .= "Número de Niños: " . $HTTP_POST_VARS["numnino"] . "\n";
$cuerpo .= "Comentarios: " . $HTTP_POST_VARS["coment"] . "\n";
//mando el correo...
mail("[email protected]","Formulario recibido",$cuerpo);
//inserto en la BD
mysql_query("INSERT INTO Reservas (res_nom, res_apel, res_dni, res_telf, res_dir, res_pob, res_ciu, res_codp, res_mail, res_tiphab, res_entrada, res_salida, res_adultos, res_ninos, res_coment)
VALUES ('$name', '$apel', '$dni', '$telf', '$direc', '$pob', '$ciudad', '$codpos', '$mail', '$habitacion', '$fechaentrada', '$fechasalida', '$numadul', '$numnino', '$coment')");
header("Location:conf.php?exito=Gracias por rellenar el formulario de reserva. Se ha enviado correctamente. La reserva será confirmada con un E-mail a su correo.");
}
?> El tema del mail funciona a la perfeccion pero a la hora de hacer el insert into, se crea un nuevo registro en la bd pero no mete las variables que yo le paso...
Agradezco por adelantado cualquier ayuda.
__________________ Bienvenidos a una nueva era. |