![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
17/04/2010, 13:01
|
![Avatar de Lutaj](http://static.forosdelweb.com/customavatars/avatar194606_2.gif) | | | Fecha de Ingreso: septiembre-2007 Ubicación: Sevilla
Mensajes: 97
Antigüedad: 17 años, 5 meses Puntos: 3 | |
Respuesta: Cómo insertar registros en dos tablas Éste es el código (simplificando lo no necesario):
<?php
$state = false;
if ($_POST['action'] == "add") {
$conexion = mysql_connect("mysqlhost5", "++++", "+++++");
mysql_select_db("+++++", $conexion);
$que = "INSERT INTO circuito (categoria, carrera, apellidos, nombre, sexo, edad, localidad, club, email, federado, numero, pagado) ";
$que.= "VALUES (
'".$_POST['categoria']."',
'".$_POST['carrera']."',
'".$_POST['apellidos']."',
'".$_POST['nombre']."',
'".$_POST['sexo']."',
'".$_POST['edad']."',
'".$_POST['localidad']."',
'".$_POST['club']."',
'".$_POST['email']."',
'".$_POST['federado']."',
'".$_POST['numero']."',
'".$_POST['pagado']."') ";
$res = mysql_query($que, $conexion) or die(mysql_error());
$state = true;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>CIRCUITO</title>
</head>
<body>
<form name="frm" method="post" action="" onSubmit ="return Verificar()">
<p><label> Carrera:</label>
<select name="carrera">
<option>carrera1
<option>carrera2
<option>carrera3
</select></p>
<p>Apellidos:
<input name="apellidos" type="text" id="apellidos" />
</p>
<p>Nombre:
<input name="nombre" type="text" id="nombre" />
</p>
<p>Sexo:
<input type="radio" name="sexo" value="H" checked />Hombre
<input type="radio" name="sexo" value="M"/>Mujer
</p>
<p>Fecha de nacimiento:
<input name="edad" type="text" id="edad" />
</p>
<p>Localidad:
<input name="localidad" type="text" id="localidad" />
</p>
<p>Club:
<input name="club" type="text" id="club" />
</p>
<p>Federado en Feder. Riojana Atletismo
<input type="radio" name="federado" value="SÍ" />SÍ
<input type="radio" name="federado" value="NO" checked />NO
</p>
<p>Número:
<input name="numero" type="text" id="numero" />
</p>
<p>Email:
<input name="email" type="text" id="email" />
</p>
<input type="submit" name="Submit" value="Inscribirme" />
<input type="hidden" name="action" value="add" />
</form>
</body>
</html> |