En la misma bd. Aquí abajo os dejo lo que tengo hecho haber si me podéis ayudar gracia
Código PHP :
<?
function abrirConexion ()
{
$dbConex = mysql_connect("localhost","","");
if (! $dbConex)
{
echo "Imposible Conectar";
exit;
}
mysql_select_db("hotel", $dbConex);
return $dbConex;
}
function cerrarConexion ($dbConex) {
mysql_close($dbConex);
}
?> Código PHP :
<html> <head> <title></title> </head> <body> <form action="reservas.php" method="post"> <input type="submit" name="enviar"value="enviar"> </p> <table width="311" border="0"> <tr> <td width="106">Nombre </td> <td width="195"><label> <input name="nombre" type="text" size="12"> </label></td> </tr> <tr> <td>Apellidos </td> <td><label> <input name="apellidos" type="text" size="30"> </label></td> </tr> <tr> </label></td> </tr> </table> <td>noches <input name="noches" type="text"></td> <p> </p> </form> </body> </html>
Código PHP :
<?
include_once("conexion.php");
$dbConex=abrirConexion();
$Nombre=$_POST["Nombre"];
$apellidos=$_POST["apellidos"];
$noches=$_POST["noches"];
function execute($Nombre, $apellidos, $noches)
{
$q1= "INSERT INTO reserva_cliente (Nombre,apellidos) values ('$Nombre','$apellidos')";
$resultquery = mysql_query($q1);
$errores = mysql_errno();
$q2= "INSERT INTO fechas (noches) values ('$noches')";
$resultquery = mysql_query($q2);
$errores = $errores + mysql_errno();
return $errores;
}
$result = execute($Nombre, $apellidos, $noches);
if ($result == 0) {
echo "guardados";
}
else
{
echo "Error al insertar datos"
}
?> 