Ver Mensaje Individual
  #16 (permalink)  
Antiguo 01/10/2009, 07:40
ingluis
 
Fecha de Ingreso: enero-2009
Mensajes: 197
Antigüedad: 15 años, 3 meses
Puntos: 0
Información Respuesta: Hacer un insert a dos tablas a la vez

Bueno este es todo el codigo completo, con el formulario incluido:

<html>
<link href="estilo.css" rel="stylesheet" type="text/css">
<?php
include_once("funciones.php");
$fecha = $_POST['fecha'];
$horaini = $_POST['horaini'];
$horafin = $_POST['horafin'];
$sala = $_POST['sala'];
$vbeam = $_POST['vbeam'];
$responsable = $_POST['responsable'];
$evento = $_POST['evento'];
if($fecha != "" && $horaini != "" && $horafin != "" && $sala != "" && $vbeam != "" && $responsable != "" && $evento != ""){
$conexion = conectar();
$vbeam = isset($_POST['vbeam'])? 1: 0; // estado del check, envia 1 si esta visible o 0 si no lo esta a la bd
IF ($_POST['sala'] == "Gerencia")
{
$sql = "insert into neiva(reserva,fecha,horaini,horafin,sala,videobeam ,responsable,evento) values('1','$fecha','$horaini','$horafin','$sala', '$vbeam','$responsable','$evento')";
$sql = "insert into bogota(reserva,fecha,horaini,horafin,sala,videobea m,responsable,evento) values('1','$fecha','$horaini','$horafin','Sala Grande(14P)--1701','$vbeam','$responsable','$evento')";
}
echo"evento grabado".$sql;
$res = mysql_query($sql);
if($res){
echo "Evento grabado";
redireccionar('3','mostrar.php');
}else{
echo "Error al grabar evento: ".mysql_error($res);
}
desconectar($conexion);
}else{
?>

<style type="text/css">
<!--
.Estilo20 { font-size: 9px;
font-weight: bold;
}
.Estilo21 {
color: #CC0000;
font-weight: bold;
font-style: italic;
}
-->
</style>
<form action="agregar.php" method="post" name="f1">
<table border=0 cellspacing="0">
<tr><td colspan="2"><span class="Estilo21">[AGREGAR EVENTO]</span></td></tr>
<tr><td>Fecha</td><td><input type="text" name="fecha" value='<? echo date("Y-m-d"); ?>'<i>Por favor respete el formato</i></td></tr>
<tr><td valign="TOP"><div align="left">
<p>Hora Inicio </p>
<p>Hora Final </p>
</div></td><td><p>
<input name="horaini" type="text" value="HH:MM:SS" />
</p>
<p>
<input name="horafin" type="text" value="HH:MM:SS" />
</p></td></tr>
<tr><td align="center"><div align="left">Sala</div></td>
<td align="center"><div align="left"><span class="Estilo20">
<select name="sala">
<option>--Seleccione--</option>
<option value="Contabilidad">Contabilidad</option>
<option value="Recursos Humanos">Recursos Humanos</option>
<option value="Auditorio">Auditorio</option>
<option value="Gerencia">Gerencia</option>
</select>
</span></div></td>
</tr>
<tr>
<td align="center"><div align="left">Video Beam
</div></td>
<td align="center"><div align="left">
<input type="checkbox" name="vbeam" value="checkbox">
</div></td>
</tr>
<tr>
<td align="center"><div align="left">Responsable
</div></td>
<td align="center"><div align="left">
<input name="responsable" type="text" size="40" maxlength="40" />
</div></td>
</tr>
<tr>
<td align="center">Observaciones</td>
<td align="center"><div align="left">
<textarea rows="5" cols="20" name="evento"></textarea>
</div></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="submit" type="submit" value="Enviar" /></td>
</tr>
</table>
</form>

<?
}
?>
</html>