Ver Mensaje Individual
  #16 (permalink)  
Antiguo 12/12/2007, 09:10
victormanuel2008
 
Fecha de Ingreso: noviembre-2007
Mensajes: 20
Antigüedad: 17 años, 2 meses
Puntos: 0
Re: ingresar 2 registros o mas a BD con campo autoincrement

Hola a todos, de hecho te hize caso pero la cja de texto del formulario aun no se contactan las cajas de texto con la aplicacion de programa.

Formulario 1
Código PHP:
<form name="form1" method="post" action="/form2.php">
<
table width="100%"  border="1" cellspacing="0" cellpadding="0">
  <
tr>
    <
td width="45%"><label>Ingrese la cantiad de Personas q desea ingresar</label></td>
    <
td width="3%"><div align="center">: </div></td>
    <
td width="32%"><input name="txtCantidad" type="text" id="txtCantidad"></td>
    <
td width="20%"><div align="center">
      <
input name="BtnAgregar" type="submit" id="BtnAgregar2" value="Agregar" style="width:120px;">
    </
div></td>
  </
tr>
</
table>
</
form
Formulario 2
Código PHP:
$cantidad=$_POST["txtCantidad"]; 
echo(
'<form name=form1 method=post action=/ingreso_con_arreglos/form3.php>
<table width=100% border=1 cellspacing=0 cellpadding=0>
  <tr>
       <td colspan=4><div align=center>Ingreso Multiple </div></td>
  </tr>
  <tr>
    <td width=25%>Nombres</td>
    <td width=25%>Apellidos</td>
    <td width=25%>Telefono</td>
    <td width=25%>Celular</td>
  </tr>'
);
    for (
$i=0$i $cantidad$i++)
      {
        echo(
'<tr> 
          <td><input name=Campo1['
.$i.'] type=text maxlength="40"></td>
          <td><input name=Campo2['
.$i.'] type=text maxlength="40"></td>
          <td><input name=Campo3['
.$i.'] type=text maxlength="12"></td>
          <td><input name=Campo4['
.$i.'] type=text maxlength="12"></td>
        </tr>'
); 
    }    
        
        echo(
'<tr>
          <td colspan=4><div align=center>
              <input name=txtCantidad type=hidden value='
.$cantidad.'>
              <input name=BtnAgregar type=submit id=BtnAgregar value=Agregar style=width:120px;>     
          </div></td>
        </tr>
    </table>
</form>'
); 
Formulario 3
Código PHP:
echo("<h1 align=center>Ingreso Multiple</h1>");
    include(
'funcion_bd.php');
    
$cantidad count($_POST["txtCantidad"]);
    
$campo1 $_POST["campo1"];
    
$campo2 $_POST["campo2"];
    
$campo3 $_POST['campo3'];
    
$campo4 $_POST['campo4'];
    echo(
$cantidad);
    for (
$i=0$i<$cantidad$i++) //Proceso de Registracion Multiple
    

        
        echo(
$campo1[$i].' '.$campo2[$i].' '.$campo3[$i].' '.$campo4[$i].'<br>');
        
//Organizo los datos
        
$ingMSQL "INSERT INTO t_dos (Nombres ,Apelido ,Telefono ,Celular)VALUES
                   ('$campo1[$i]', '$campo2[$i]', '$campo3[$i]', '$campo4[$i]')"
;
        
//guardo los datos
        
echo($ingMSQL);
        
$resultadoMSQL mysql_query($ingMSQL);
        if (
$resultadoMSQL//Si guardo entonces me indicara que hizo esta operacion
             
echo "Ha ingresado exitosamente la Unidad: ";
        else 
//En caso de no guardar los datos y en indicara un mensaje de error en el proceso
             
echo('no se puede ingresar datos<br>');
         
    } 
Y sigue el mismo problema.