Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/02/2010, 05:05
tecla2
 
Fecha de Ingreso: julio-2007
Mensajes: 48
Antigüedad: 19 años, 2 meses
Puntos: 0
dos formularios en la misma página

hola,
tengo dos formularios en una misma página.
El primero tiene un select con dnis de personas
En el segundo quiero mostrar los datos de la persona a la q corresponda el dni elegido en el select.
¿Cómo cojo el dato dni del primer formulario?

Código PHP:
<form name="eligeDni" method="post" action=""> 
//primer formulario
<table align="center" cellspacing="10px">
 <tr align="center">
  <td>Dni:</td>
  <td><select name="dni">
           <option selected
    <?php
          
include("../auxi/conexionbd.php");
          
$conexion = conectaBD();
          
$sql = "select dni from socio";
          
$resultado = mysql_query($sql,$conexion);
          while (
$row=mysql_fetch_array($resultado)){
             
printf ("<option>%s</option>",$row["dni"]);
           }
    
?>
   </select></td>
  </tr>
</table>
</form>

<?php
  
// quiero recoger el dato dni del select anterior    
  // NO FUNCIONA --> $dni = $_POST['dni'];
  //recojo resultados
  
$sql = "select * from persona where dni='".$dni."'";
  
$resultado = mysql_query($sql,$conexion);
  if (
$row=mysql_fetch_array($resultado)){
    
$nombre = $row["nombre"];
    
$ape1 = $row["apellido1"];
  }
?>
//segundo formulario (dnd muestro los resultados obtenidos)
<form name="modSocio" method="post"> 
  <table align="center" cellspacing="10px">
    <tr align="center">
      <td>Nombre:</td>
      <td><input type="text" name="nombre" value="<?php echo "$nombre" ?>"></td>
    </tr>
    <tr align="center">
      <td>Apellido 1:</td>
      <td><input type="text" name="apellido1" value="<?php echo "$ape2" ?>"></td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input type="submit" name="enviar" value="Modificar socio"><input type="reset" name="cancelar" value="Cancelar"></td>
    </tr>
  </table>
</form>