![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
07/10/2010, 08:01
|
| | Fecha de Ingreso: octubre-2010
Mensajes: 3
Antigüedad: 14 años, 4 meses Puntos: 0 | |
reservas hola serian tan amable de ayudarme con la siguiente duda hice un formulario de agregar reserva y me agrega pero cuando ingreso la misma reserva me la vuelve agregar necesito validar para que no me permita ingresar la misma y salga el mensaje de no estar disponible
<?php
include("config.php");
$dia=$_POST['dia'];
$mes=$_POST['mes'];
$ano=$_POST['ano'];
$hora=$_POST['hora'];
$minutos=$_POST['minutos'];
$dia1=$_POST['dia1'];
$mes1=$_POST['mes1'];
$ano1=$_POST['ano1'];
$hora1=$_POST['hora1'];
$minutos1=$_POST['minutos1'];
$observaciones=$_POST['observaciones'];
$instructor=$_POST['instructor'];
$fecha_reserva=$ano."-".$mes."-".$dia;
$hora_reserva=$hora.":".$minutos;
$fecha_entrega=$ano1."-".$mes1."-".$dia1;
$hora_entrega=$hora1.":".$minutos1;
$espacio=$_POST['espacio'];
$mysql_enlace=mysql_connect($servidor,$usuario,$cl ave);
mysql_select_db($bd,$mysql_enlace);
$consulta="select * from reserva where
fecha_inicio != '$fecha_reserva' and
fecha_final != '$fecha_entrega' and
tiempo_inicio != '$hora_reserva' and
tiempo_final != '$hora_entrega' and
idespacios != '$espacio'";
$res=mysql_query($consulta,$mysql_enlace);
if (mysql_num_rows($res)== 0)
{
$consulta1="insert into reserva values('0',now(),'$fecha_reserva','$fecha_entrega' ,'$hora_reserva','$hora_entrega','1','1','$observa ciones','$instructor','$espacio')";
$resultado=mysql_query($consulta1,$mysql_enlace);
echo '<html>
<head>
<title>mensaje</title>
</head>
<body>
<script language="javascript">
alert("La reserva fue realizada");
document.location="reserva.php";
</script>
</body>
</html>';
}
else
{
echo '<html>
<head>
<title>mensaje</title>
</head>
<body>
<script language="javascript">
alert("la reserva ya existe");
document.location="reserva.php";
</script>
</body>
</html>';
}
?> |