Cita:
Iniciado por egepe
Eso es exactamente lo que yo les dije lo que pasa es que se los explique no le dije que hicieran un header como tu...
![de acuerdo](http://static.forosdelweb.com/fdwtheme/images/smilies/dedosarriba.png)
este es el codigo del formulario:
<?php
include("config.php");
$mysql_enlace=mysql_connect($servidor,$usuario,$cl ave);
mysql_select_db($bd,$mysql_enlace);
$select="select * from usuarios where idrol=2 and estado=1";
$resultado=mysql_query($select,$mysql_enlace);
?>
<html>
<head>
<title>AGREGAR RESERVA</title>
<!--se llama la pagina donde estan las validadiones-->
<script src="../../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script language="javascript" src="validar.js"></script>
<link href="css/calendario.css" type="text/css" rel="stylesheet">
<script src="js/calendar.js" type="text/javascript"></script>
<script src="js/calendar-es.js" type="text/javascript"></script>
<script src="js/calendar-setup.js" type="text/javascript"></script>
</head>
<body oncontextmenu="return false"></body> <!-- para que no puedan ingresar texto y se coloca en el body: onkeydown="return false"-->
<br>
<br>
<br>
<br>
<center><b><font color="#008844" size="5">Agregar reserva</font></b></center>
<hr></hr>
<table align="center" width="95%" background="../img/Dibujo1.JPG">
<tr>
<td>
<form action="agregar_reservaaccion.php" method="post" name="agregar_reserva">
<table align="center" border="2" bordercolor="#005B5B">
<tr>
<td><b>Fecha inicio *</b></td>
<td><input type="text" name="fechainicio" id="ingreso"/> <!--value="dd-mm-yyyy" -->
<img src="ima/calendario.png" width="16" height="16" border="0" title="Fecha inicial de la reserva" id="lanzador">
<!-- script que define y configura el calendario-->
<script type="text/javascript">
Calendar.setup({
inputField : "ingreso", // id del campo de texto
ifFormat : "%Y-%m-%d", // formato de la fecha que se escriba en el campo de texto
button : "lanzador" // el id del botón que lanzará el calendario
});
</script></td>
<td><b>Fecha final *</b></td>
<td><input type="text" name="fechafinal" id="fin"/> <!--value="dd-mm-yyyy" -->
<img src="ima/calendario.png" width="16" height="16" border="0" title="Fecha inicial de la reserva" id="lanzador1">
<!-- script que define y configura el calendario-->
<script type="text/javascript">
Calendar.setup({
inputField : "fin", // id del campo de texto
ifFormat : "%Y-%m-%d", // formato de la fecha que se escriba en el campo de texto
button : "lanzador1" // el id del botón que lanzará el calendario
});
</script></td>
</tr>
<tr>
<td><b>Hora inicio </b></td>
<td><input type="text" name="horainicio" id= "fecha" onkeyup="Validar(this,':',patron,true)" maxlength="5" /></td>
<td><b>Hora final *</b></td>
<td><input type="text" name="horafinal" id= "fecha" onkeyup="Validar(this,':',patron,true)" maxlength="5" /></td>
</tr>
<tr>
<td colspan="4"><b><center>Observaciones</center></b></td>
</tr>
<tr>
<td colspan="4"><center><textarea rows="5" cols="50" name="observaciones"></textarea></center></td>
</tr>
<tr>
<td colspan="2"><b>Instructor encargado*</b></td>
<td colspan="2"><center><select name="instructor">
<option value="">- - - - - - - - - -</option>
<?php
while ($registro=mysql_fetch_array($resultado))
{
echo '<option value="'.$registro['idusuarios'].'">'.$registro['primer_nombre'].' '.$registro['primer_apellido'].'</option>';
}
?>
</select></center></td>
</tr>
<tr>
<td colspan="2"><b>Espacio *</b></td>
<td colspan="2"><center><select name="espacio">
<option value="">- - - - - - - - - - - - - - -</option></option>
<?php
include("config.php");
$mysql_enlace=mysql_connect($servidor,$usuario,$cl ave);
mysql_select_db($bd,$mysql_enlace);
$consulta="select * from espacios";
$resultado1=mysql_query($consulta,$mysql_enlace);
while ($registro1=mysql_fetch_array($resultado1))
{
echo '<option value="'.$registro1['idespacios'].'">'.$registro1['nombre'].'</option>';
}
?>
</select></center></td>
</tr>
<input type="hidden" name="estado" value="1">
<tr>
<td colspan="4"><center><input name="enviar" type="button" value="Agregar" onClick="reserva();"/><input type="reset" value="Limpiar"></center></td>
</tr>
</table>
<br>
<br>
</td>
</tr>
</table>
</form>
</body>
</html>
y este es el codigo de php para la insercion:
<?php
include("config.php");
//se definen las variables que traigo del formulario
$fechainicio=$_POST['fechainicio'];
$fechafinal=$_POST['fechafinal'];
$horainicio=$_POST['horainicio'];
$horafinal=$_POST['horafinal'];
$observaciones=$_POST['observaciones'];
$instructor=$_POST['instructor'];
$espacio=$_POST['espacio'];
$estado=$_POST['estado'];
//se hace la conexion a la base de datos
$mysql_enlace=mysql_connect($servidor,$usuario,$cl ave);
mysql_select_db($bd,$mysql_enlace);
//se realiza la consulta para verificar si la reserva ya existe
$consultatodo="select * from reserva where
fecha_inicio != '$fechainicio' and
fecha_final != '$fechafinal' and
tiempo_inicio != '$horainicio' and
tiempo_final != '$horafinal' and
idespacios != '$espacio'";
$resultadotodo=mysql_query($consultatodo,$mysql_en lace);
$registro=mysql_num_rows($resultadotodo);
//if(mysql_num_rows($resultadotodo)=="0")
if (mysql_num_rows($resultadotodo)== 0)
{
$consulta="insert into reserva values('',now(),'$fechainicio','$fechafinal','$hor ainicio','$horafinal','1','$estado','$observacione s','$instructor','$espacio')";
$resultado=mysql_query($consulta,$mysql_enlace);
echo $consulta;
if($resultado)
{
echo '<html>
<head>
<title>mensaje</title>
</head>
<body>
<script language="javascript">
alert("La reserva fue realizada");
//document.location="agregar_reserva.php";
</script>
</body>
</html>';
}
else
{
echo '<html>
<head>
<title>.::.</title>
</head>
<body>
<script language="javascript">
alert("OJO: la reserva no se realizo");
//document.location="agregar_reserva.php";
</script>
</body>
</html>';
}
}
else
{
echo '<html>
<head>
<title>mensaje</title>
</head>
<body>
<script language="javascript">
alert("la reserva ya existe");
//document.location="agregar_reserva.php";
</script>
</body>
</html>';
}
?>
gracias por su colaboracion...