Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/08/2013, 11:11
desoler
 
Fecha de Ingreso: agosto-2008
Ubicación: Miami, FL
Mensajes: 210
Antigüedad: 15 años, 8 meses
Puntos: 2
Pregunta dos formularios juntos

Hola gente,
A ver si alguien me aclara la cabeza.
Tengo el codigo y me funciona a medias.
en una misma pagina tengo dos formularios con select submit, el primero me lo ejecuta bien, pero el segundo no.
Este es el codigo:

Código PHP:
Ver original
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Documento sin título</title>
  6. </head>
  7.  
  8. <body>
  9. <?php
  10.  
  11. $first_name = $_POST['nombre'];
  12. $last_name = $_POST['apellido'];
  13. $address = $_POST['address'];
  14. $pickup_city = $_POST['pickup_city'];
  15. $pickup_state = $_POST['pickup_state'];
  16. $pickup_zip_code = $_POST['pickup_zip_code'];
  17. $phone = $_POST['phone'];
  18.  
  19. ?>
  20.  
  21.  
  22. <form id="form1" name="form1" method="post" action="pickup.php">
  23.   <select name="datos" id="datos" onchange="this.form.submit();">
  24.      <option value="">select one</option>
  25.      <option value="10663">Client</option>
  26.      <option value="1">Trailer Bridge Jack.</option>
  27.      <option value="2">Trailer Bridge PR.</option>
  28.      <option value="3">Crowley NJ.</option>
  29.      <option value="4">Crowley PR.</option>
  30.      <option value="5">Sea Star Line Jack.</option>
  31.      <option value="6">Sea Star Line PR.</option>
  32.      <option value="7">Sea Star Line EV.</option>
  33.   </select>
  34. <br />  
  35. <br />Pickup Contact<br />  
  36. <br />
  37.  
  38.    Terminal :<input name="first_name" type="text" id="first_name" value="<?php echo $first_name ?>"  /> <br />
  39.    Contact :<input name="last_name" type="text" id="last_name" value="<?php echo $last_name ?>"  /> <br />
  40.    Buyer Number :<input name="buyer_number" type="text" id="buyer_number" value=""  /> <br />
  41.    Address :<input name="address" type="text" id="address" value="<?php echo $address ?>"  /> <br />
  42.    Pickup  :<input name="pickup_city" type="text" id="pickup_city" value="<?php echo $pickup_city ?>"  /> <input name="pickup_state_code" type="text" id="pickup_state_code" value="<?php echo $pickup_state_code ?>" size="3" /> <input name="pickup_zip_code" type="text" id="pickup_zip_code" value="<?php echo $pickup_zip_code ?>" size="6" />
  43.    Phone: <input name="phone" type="text" id="phone" value="<?php echo $phone ?>"  /> <br />
  44.  
  45. </fom>
  46. <br />
  47.  
  48. <?php
  49.  
  50. $first_name_dropoff = $_POST['nombre_dropoff'];
  51. $last_name_dropoff = $_POST['apellido_dropoff'];
  52. $address_dropoff = $_POST['address_dropoff'];
  53. $dropoff_city = $_POST['dropoff_city'];
  54. $dropoff_state = $_POST['dropoff_state'];
  55. $dropoff_zip_code = $_POST['dropoff_zip_code'];
  56. $phone_dropoff = $_POST['phone_dropoff'];
  57.  
  58. ?>
  59.  
  60. <form id="form2" name="form2" method="post" action="dropoff.php">
  61.   <select name="datos2" id="datos2" onchange="this.form.submit();">
  62.      <option value="">select one</option>
  63.      <option value="10663">Client</option>
  64.      <option value="1">Trailer Bridge Jack.</option>
  65.      <option value="2">Trailer Bridge PR.</option>
  66.      <option value="3">Crowley NJ.</option>
  67.      <option value="4">Crowley PR.</option>
  68.      <option value="5">Sea Star Line Jack.</option>
  69.      <option value="6">Sea Star Line PR.</option>
  70.      <option value="7">Sea Star Line EV.</option>
  71.   </select>
  72. <br />  
  73. </br />Delivery Contact<br />
  74. <br />
  75.  
  76.    Terminal :<input name="first_name_dropoff" type="text" id="first_name_dropoff" value="<?php echo $first_name_dropoff ?>"  /> <br />
  77.    Contact :<input name="last_name_dropoff" type="text" id="last_name_dropoff" value="<?php echo $last_name_dropoff ?>"  /> <br />
  78.    Buyer Number :<input name="buyer_number" type="text" id="buyer_number" value=""  /> <br />
  79.    Address :<input name="address_dropoff" type="text" id="address_dropoff" value="<?php echo $address_dropoff ?>"  /> <br />
  80.    Pickup  :<input name="dropoff_city" type="text" id="dropoff_city" value="<?php echo $dropoff_city ?>"  /> <input name="dropoff_state_code" type="text" id="dropoff_state_code" value="<?php echo $dropoff_state_code ?>" size="3" /> <input name="dropoff_zip_code" type="text" id="dropoff_zip_code" value="<?php echo $dropoff_zip_code ?>" size="6" />
  81.    Phone: <input name="phone_dropoff" type="text" id="phone_dropoff" value="<?php echo $phone_dropoff ?>"  /> <br />
  82.  
  83. </fom>
  84. </body>
  85. </html>

cada formulario llama otro php que ejecuta la peticion:

Código PHP:
Ver original
  1. <?php
  2.  
  3. $cliente = $_POST['datos'];
  4.  
  5. //1. Crear conexión a la Base de Datos
  6. $conexion = mysql_connect("localhost","yo","contra");
  7. if (!$conexion) {
  8. die("Fallo la conexión a la Base de Datos: " . mysql_error());
  9. }
  10. //2. Seleccionar la Base de Datos a utilizar
  11. $seleccionar_bd = mysql_select_db("mi_base", $conexion);
  12. if (!$seleccionar_bd) {
  13. die("Fallo la selección de la Base de Datos: " . mysql_error());
  14. }
  15.  
  16. $datos_sql = mysql_query("SELECT * FROM quoted WHERE personalID='".$cliente."'");
  17. while ($fila = mysql_fetch_array($datos_sql))
  18. {
  19. echo'
  20.  
  21. <form name="auxiliar" id="auxiliar" method="post" action="order.php">
  22.  <input type="hidden" name="nombre" value="'.$fila['first_name'].'" />
  23.   <input type="hidden" name="apellido" value="'.$fila['last_name'].'" />
  24.   <input type="hidden" name="address" value="'.$fila['address'].'" />
  25.   <input type="hidden" name="pickup_city" value="'.$fila['pickup_city'].'" />
  26.   <input type="hidden" name="pickup_state_code" value="'.$fila['pickup_state_code'].'" />
  27.   <input type="hidden" name="pickup_zip_code" value="'.$fila['pickup_zip_code'].'" />
  28.   <input type="hidden" name="phone" value="'.$fila['phone'].'" />
  29. </form>
  30.  
  31. <script type="text/javascript">
  32.  document.auxiliar.submit();
  33. </script>
  34. ';
  35. }
  36. ?>

el segundo codigo al que llama es:

Código PHP:
Ver original
  1. <?php
  2.  
  3. $cliente = $_POST['datos2'];
  4.  
  5. //1. Crear conexión a la Base de Datos
  6. $conexion = mysql_connect("localhost","yo","contra");
  7. if (!$conexion) {
  8. die("Fallo la conexión a la Base de Datos: " . mysql_error());
  9. }
  10. //2. Seleccionar la Base de Datos a utilizar
  11. $seleccionar_bd = mysql_select_db("mi_base", $conexion);
  12. if (!$seleccionar_bd) {
  13. die("Fallo la selección de la Base de Datos: " . mysql_error());
  14. }
  15.  
  16. $datos_sql = mysql_query("SELECT * FROM quoted WHERE personalID='".$cliente."'");
  17. while ($fila = mysql_fetch_array($datos_sql))
  18. {
  19. echo'
  20.  
  21. <form name="auxiliar" id="auxiliar" method="post" action="order.php">
  22.  <input type="hidden" name="nombre_dropoff" value="'.$fila['first_name'].'" />
  23.   <input type="hidden" name="apellido_dropoff" value="'.$fila['last_name'].'" />
  24.   <input type="hidden" name="address_dropoff" value="'.$fila['address'].'" />
  25.   <input type="hidden" name="dropoff_city" value="'.$fila['dropoff_city'].'" />
  26.   <input type="hidden" name="dropoff_state_code" value="'.$fila['dropoff_state_code'].'" />
  27.   <input type="hidden" name="dropoff_zip_code" value="'.$fila['dropoff_zip_code'].'" />
  28.   <input type="hidden" name="phone_dropoff" value="'.$fila['phone'].'" />
  29. </form>
  30.  
  31. <script type="text/javascript">
  32.  document.auxiliar.submit();
  33. </script>
  34. ';
  35. }
  36. ?>

al hacer el onchange del primero me carga los datos correctamente, pero al hacer el onchange del segundo me vuelve a ejecutar el primero.

Desde ya muchas gracias por el tiempo prestado
__________________
Se invierte mas dinero en cirugía de pechos y viagra que en la cura del Alzheimer. En unos años tendremos viejas con grandes tetas y viejos con erecciones pero que no recordarán para que sirven..