Ver Mensaje Individual
  #5 (permalink)  
Antiguo 04/05/2013, 13:52
snowmanchip
 
Fecha de Ingreso: agosto-2011
Ubicación: Viña del Mar, Chile
Mensajes: 311
Antigüedad: 13 años, 5 meses
Puntos: 50
Respuesta: Cargar datos de un formulario en otra pagina con php y Mysql

Hola Cafu, creo que el problema no es de PHP si no más bien de la interfaz o el FronEnd, como sugerencia te recomiendo tabular el formulario con Javascrip o Jquery, pero como quizá el tema va por otro lado te muestro una forma de hacerlo... espero no lo apliques tal cuál es sólo un ejemplo que espero te resulte ,
Paso 1
Código HTML:
Ver original
  1. <!DOCTYPE html>
  2.     <head>
  3.         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  4.        
  5.         <title>Paso1</title>
  6.     </head>
  7.     <body>
  8.         <form action="paso2.php" method="post">
  9.             <div>
  10.                 <label for="nombre">Email</label>
  11.                 <div>
  12.                     <input type="text" name="nombre" placeholder="Nombre">
  13.                 </div>
  14.             </div>
  15.             <div>
  16.                 <labelfor="inputPassword">Dirección</label>
  17.                 <div>
  18.                     <input type="text" name="direccion1" placeholder="Dirección Principal">
  19.                 </div>
  20.             </div>
  21.             <div>
  22.                 <labelfor="inputPassword">Teléfono</label>
  23.                 <div>
  24.                     <input type="text" name="telefono" placeholder="Teléfono">
  25.                 </div>
  26.             </div>
  27.             <div >
  28.                                
  29.                 <button type="submit">Paso2</button>
  30.             </div>
  31.         </form>
  32.     </body>
  33. </html>
Paso 2
Código PHP:
Ver original
  1. $nombre = $_POST['nombre'];
  2.     $telefono = $_POST['telefono'];
  3.     $direccion1 = $_POST['direccion1'];
  4.  
  5.  
  6.  
  7. ?>
  8. <!DOCTYPE html>
  9. <html>
  10.     <head>
  11.         <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  12.        
  13.         <title>Paso2</title>
  14.     </head>
  15.     <body>
  16.         <form action="paso3.php" method="post">
  17.             <div>
  18.                 <label for="Email">Email</label>
  19.                 <div>
  20.                     <input type="text" name="email" placeholder="Email">
  21.                 </div>
  22.             </div>
  23.             <div>
  24.                 <labelfor="inputPassword">Rubro</label>
  25.                 <div>
  26.                     <input type="text" name="rubro" placeholder="Rubro">
  27.                 </div>
  28.             </div>
  29.             <div>
  30.                 <labelfor="inputPassword">Dirección Alternativa</label>
  31.                 <div>
  32.                     <input type="text" name="direccion2" placeholder="<?php echo $direccion1 ?>">
  33.                 </div>
  34.             </div>
  35.             <div>
  36.                     <input type="hidden" name="nombre" value ="<?php echo $nombre ?>">
  37.             </div>
  38.             <div>
  39.                 <input type="hidden" name="telefono" value ="<?php echo $telefono ?>">
  40.             </div>
  41.             <div>
  42.                 <input type="hidden" name="direccion1" value ="<?php echo $direccion1 ?>">
  43.             </div>
  44.             <div>
  45.                
  46.                     <label>
  47.                         <input type="checkbox"> Mantener Dirección Principal
  48.                     </label>
  49.                 <button type="submit">Grabar</button>
  50.                
  51.             </div>
  52.         </form>
  53.     </body>
  54. </html>
Paso 3
Código HTML:
Ver original
  1. <?php
  2. $bd=mysql_connect("localhost","root","") or die ("no puedo conectarme");
  3. mysql_select_db("formulariobd");
  4.  
  5. $email = $_POST['email'];
  6. $rubro = $_POST['rubro'];
  7. $nombre = $_POST['nombre'];
  8. $telefono = $_POST['telefono'];
  9. $direccion1 = $_POST['direccion1'];
  10. if (empty($_POST['direccion2'])) {
  11.     $direccion2 = $direccion1;
  12.    
  13. }
  14. else {
  15. $direccion2 = $_POST['direccion2'];
  16. }
  17. $sql="insert into datos (nombre,direccion1, telefono, rubro, direccion2, email) values ('$nombre','$direccion1','$telefono','$rubro', '$direccion2', '$email')";
  18. $res=mysql_query($sql,$bd) or die (mysql_error());
  19.  
  20.  
  21. ?>
  22. <h1>Datos Ok</h1>

Saludos