Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/05/2012, 09:12
Lissett Martinez
 
Fecha de Ingreso: febrero-2007
Ubicación: Carrizal - Miranda
Mensajes: 7
Antigüedad: 17 años, 2 meses
Puntos: 0
Información Llenar un Formulario e Insertar los datos en mysql y pasar a llenar otro formulario

Buen Dia
Estoy tratando de que al llenar un formulario, en el mismo se inserte en la BD mysql la informacion llenada y de alli pasar a otro formulario. Este es el codigo
Código PHP:
Ver original
  1. <?php
  2. $nacionalidad =$_POST['nacionalidad'];
  3. $cedula = $_POST['cedula_usuario'];
  4. $nombre = $_POST['nombre_usuario'];
  5. $apellido = $_POST['apellido_usuario'];
  6. $nacimiento =$_POST['lugar_nac'];
  7. $fecha_nac =$_POST['fecha_nac'];
  8. $civil = $_POST['descripcion_civil'];
  9. $edad = $_POST['edad'];
  10. $sexoU = $_POST['sexoU'];
  11. $instruccion = $_POST['descripcion_instruccion'];
  12. $ocupacion = $_POST['id_ocupacion'];
  13. $municipios =$_POST['id_municipios'];
  14. $sector = $_POST['sector'];
  15. $calle = $_POST['calle'];
  16. $nom_edif_casa = $_POST['nom_edif_casa'];
  17. $piso = $_POST['piso'];
  18. $pto_referen = $_POST['pto_referen'];
  19. $codfijo = $_POST['codfijo'];
  20. $telefono = $_POST['telefono'];
  21. $celular = $_POST['celular'];
  22. $codcel = $_POST['codcel'];
  23. include("include/conexion.php");
  24. ?>
  25. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  26. <head>
  27. <script language="JavaScript"  src="calendar/calendar_us.js"></script>
  28. <link  rel="stylesheet"  href="calendar/calendar.css">
  29. </head>
  30.  
  31. <body>
  32. <form id="acta_entrevista_i" name="form1" method="post" >
  33. <table width="958" border="0" align="center">
  34.     <tr>
  35.       <td colspan="2"><label for="cedula_usuario"></label></td></tr>
  36.     <tr><td colspan="2" bgcolor="#CCCCCC"><div align="left"><strong>DATOS PERSONALES DE USUARIA</strong></div></td></tr>
  37.     <tr><td height="161" colspan="2"><table width="94%" border="0">
  38.         <tr><td colspan="5" nowrap="nowrap">Nombre(s):<label for="nombre_usuario"></label>
  39.             <input name="nombre_usuario" type="text" id="nombre_usuario" size="50" onKeyPress="return validar(event)"/></td>
  40.           <td colspan="4" nowrap="nowrap">Apellido(s):<label for="apellido_usuario">
  41.               <input name="apellido_usuario" type="text" id="apellido_usuario" size="50" onkeypress="return validar(event)"/></label>
  42.               </td></tr><tr> <td colspan="5" nowrap="nowrap">Lugar de Nacimiento:<label for="lugar_nac"></label>
  43.             <input name="lugar_nac" type="text" id="lugar_nac" size="50" onKeyPress="return validar(event)"/></td>
  44.           <td colspan="2" nowrap="nowrap">Fecha de Nacimiento:</td>
  45.           <td colspan="2" nowrap="nowrap"><label for=""></label>
  46.             <input type="text" name="fecha_nac" id="fecha_nac" />  
  47.             <script language="JavaScript">
  48.                 //Genera un Calendario
  49.                 new tcal ({
  50.                 // Nombre del formulario
  51.                 'formname': 'acta_entrevista_i',
  52.                 // Nombre del input
  53.                 'controlname': 'fecha_nac'
  54.                 });
  55.             </script> </td> </tr><tr>
  56.           <td width="5%" nowrap="nowrap">C&eacute;dula.:</td>
  57.           <td width="4%" nowrap="nowrap">
  58.             <select name="nacionalidad" id="nacionalidad">
  59.               <option value="V">V</option>
  60.               <option value="E">E</option>
  61.             </select></td>
  62.           <td width="13%" nowrap="nowrap"><label for="mayores"></label>
  63.             <input type="text" name="cedula_usuario" id="cedula_usuario" onKeyPress="return numeros(event)" /></td>
  64.           <td width="6%" nowrap="nowrap">Edo. Civil</td>
  65.           <td width="26%" nowrap="nowrap"><label for="descripcion_civil"></label>
  66.             <select name="descripcion_civil" id="descripcion_civil">
  67.             <?php     $total = mysql_num_rows($res);
  68.                  for ($i=0;$i <$total;$i++){
  69.                     $registro = mysql_fetch_array($res);
  70.                     echo "<option value='".$registro['id_edo_civil']."'>".$registro['descripcion_civil']."</option>\n";
  71.                     }?>
  72.                   <option value="0" selected="selected">... Seleccione ... </option>
  73.             </select></td>
  74.           <td width="3%" nowrap="nowrap">&nbsp;</td>
  75.           <td width="8%" nowrap="nowrap">&nbsp;</td>
  76.           <td width="7%" nowrap="nowrap"><div align="right">Sexo:</div></td>
  77.           <td width="28%" nowrap="nowrap"><label for="sexo"></label>
  78.             <div align="left">
  79.               <input type="radio" name="sexoU" id="radio" value="M" />
  80.               Masculino
  81.               <input type="radio" name="sexoU" id="radio2" value="F" />
  82.             Femenino</div></td>
  83.         </tr>
  84.         <tr>
  85.           <td colspan="5" nowrap="nowrap">Nivel de Instrucci&oacute;n:
  86.             <label for="descripcion_instruccion"></label>
  87.             <select name="descripcion_instruccion" id="descripcion_instruccion">
  88.                     <?php   $total = mysql_num_rows($res3);
  89.                  for ($i=0;$i <$total;$i++){
  90.                     $registro = mysql_fetch_array($res3);
  91.                     echo "<option value='".$registro['id_instruccion']."'>".$registro['descripcion_instruccion']."</option>\n";}        ?>
  92.                 <option value="0" selected="selected">... Seleccione ... </option>
  93.             </select></td>
  94.           <td colspan="4" nowrap="nowrap">Ocupaci&oacute;n actual:
  95.             <label for="id_ocupacion"></label>
  96.             <select name="id_ocupacion" id="id_ocupacion">
  97.              <?php   $total = mysql_num_rows($res4);
  98.                  for ($i=0;$i <$total;$i++){
  99.                     $registro = mysql_fetch_array($res4);
  100.                     echo "<option value='".$registro['id_ocupacion']."'>".$registro['descripcion_ocupacion']."</option>\n";}    ?>
  101.                 <option value="0" selected="selected">... Seleccione ... </option>
  102.              </select></td>
  103.         </tr></table>
  104.        
  105.      </form>
  106. <form name="formulario" method="post">
  107.   <table width="995" border="0" align="center">
  108.   <tr>
  109.     <td colspan="3">Tiene Hijo(s):      No
  110.       <input type="radio" name="radios" value="no" onchange="formulario.action='caso.php';" />
  111.         Si        <input type="radio" name="radios" value="yes" onchange="formulario.action='SeHijo.php';" /></td>
  112.   </tr>  <tr>
  113.     <td colspan="3"><div align="left">
  114.       <input type="submit" name="enviar" value="Siguiente"  />    </div></td>
  115.   </tr>  <tr>
  116.     <td colspan="3">&nbsp;</td>  </tr>  </table>
  117. </form></body></html>
  118. <?php
  119. $sql = "INSERT INTO datos_basicos (id_caso, nacionalida, cedula_usuario, nombre_usuario, apellido_usuario, sexoU, fecha_nac, lugar_nac, id_edo_civil, id_instruccion, id_ocupacion, id_municipio, edad, calle, nom_edif_casa, piso, apto, casa_nro, pto_referen, telefono, celular, id_empresa, sector, id_relacion) VALUES (0,'$nacionalidad', $cedula,'$nombre','$apellido','$sexoU','$nuevaFecha','$nacimiento','$civil','$instruccion',$ocupacion,$municipios,$calculoEdad,'$calle','$nom_edif_casa','$piso',0,0,'$pto_referen','$telefono','$celular',0,'$sector', $relacion)";
  120.  mysql_query($sql);
  121. $res = mysql_query($sql,$conex);
  122. ?>
SI ALGUIEN ME PUEDE ORIENTAR GRACIAS, YA QUE NO ME INSERTA Y LA VERDAD NO SE COMO HACERLO. GRACIAS

Última edición por Lissett Martinez; 08/05/2012 a las 14:07 Razón: para que se vea mejor el codigo