Foros del Web » Programando para Internet » PHP »

PHP OO Problemas al ingresar datos a la base de datos

Estas en el tema de Problemas al ingresar datos a la base de datos en el foro de PHP en Foros del Web. Este es la primera parte del programa, es largo, solo me ingresa num_unico a la base de datos: Por favor ayuda: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código PHP: ...
  #1 (permalink)  
Antiguo 11/05/2015, 09:24
 
Fecha de Ingreso: abril-2015
Ubicación: Santiago de Chile
Mensajes: 80
Antigüedad: 8 años, 11 meses
Puntos: 0
Problemas al ingresar datos a la base de datos

Este es la primera parte del programa, es largo, solo me ingresa num_unico a la base de datos: Por favor ayuda:

Código PHP:
Ver original
  1. <?
  2. ?>
  3. <?
  4. include "conectar.php";
  5. ?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  7.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  8.  
  9. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  10.  
  11. <script language="JavaScript">
  12. function tabular(e,obj) {
  13.   tecla=(document.all) ? e.keyCode : e.which;
  14.   if(tecla!=13) return;
  15.   frm=obj.form;
  16.   for(i=0;i<frm.elements.length;i++)
  17.     if(frm.elements[i]==obj) {
  18.       if (i==frm.elements.length-1) i=-1;
  19.       break }
  20.   frm.elements[i+1].focus();
  21.   return false;
  22. }
  23. function tabular2(e,obj) {
  24.   tecla=(document.all) ? e.keyCode : e.which;
  25.   if (tecla>13 && tecla < 48){return false;}
  26.   if (tecla>57){return false;}
  27.   if(tecla!=13) return;
  28.   frm=obj.form;
  29.   for(i=0;i<frm.elements.length;i++)
  30.     if(frm.elements[i]==obj) {
  31.       if (i==frm.elements.length-1) i=-1;
  32.       break }
  33.   frm.elements[i+1].focus();
  34.   return false;
  35. }
  36. </script>
  37.   <head>
  38.  
  39.     <title>Ingreso de Equipos</title>
  40.  
  41.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  42. <!--
  43. .Estilo1 {
  44.     font-size: 18px;
  45.     color: #FFFFFF;
  46. }
  47. .Estilo3 {color: #FFFFFF}
  48. .Estilo4 {
  49.     font-size: 16px;
  50.     color: #FFFFFF;
  51. }
  52. -->
  53.     </style>
  54.     <style type="text/css">
  55. <!--
  56. .Estilo4 {font-size: 36px}
  57. .Estilo5 {font-size: 18px}
  58. .Estilo6 {font-size: 24px}
  59. -->
  60.     </style>
  61. </head>
  62.   <body>
  63.   <p>
  64.     <?
  65. /* include "encabezado.php"; */
  66. ?>
  67.   </p>
  68.   <table border="0">
  69.     <tr>
  70.       <th scope="col"><img src="imagenes/logoinformatica.jpg" width="182" height="53" /></th>
  71.       <th scope="col"><span class="Estilo3 Estilo4">&quot;Ingreso de Equipos&quot;</span></th>
  72.     </tr>
  73.   </table>
  74.   <p><br>
  75.     <br>
  76. </p>
  77.   <div class="content">
  78.     <form method="POST" name="form1" action="ingreso_stock.php">
  79. <table border="1" width="100%">
  80. <tr>
  81.   <td colspan="2" bgcolor="#00FFFF"><span class="Estilo1 Estilo6">Usuario</span></td>
  82.   </tr>
  83. <tr>
  84.   <td bgcolor="#00FFFF"><span class="Estilo5">Seleccione el usuario
  85.    
  86.   </span></td>
  87.   <td bgcolor="#00FFFF">
  88.   <select name="usuario" onkeypress="return tabular(event,this)">
  89. <? //por área
  90. $result = mysql_query("SELECT * FROM usuarios  WHERE  vigente ='S' order by nombre_largo");
  91. if (mysql_num_rows($result)>0){
  92.    $i=0;
  93.    $rows=mysql_num_rows($result);
  94.    while($i < $rows) {
  95.    
  96.       if ($_POST["usuario"]==mysql_result($result, $i, "num_unico")){
  97.         echo("<option selected value=".mysql_result($result, $i, "num_unico").">".mysql_result($result, $i, "nombre_largo")."</option>");
  98.         }else{
  99.         echo("<option value=".mysql_result($result, $i, "num_unico").">".mysql_result($result, $i, "nombre_largo")."</option>");
  100.         }
  101.    $i++;
  102.    }
  103. }
  104. ?>
  105. </select></td>
  106. </tr>
  107. </table>
  108. <input type="submit" value="Mostrar">
  109. </form>
  110.  
  111. <?
  112. if ($_POST["usuario"]!=""){
  113. //selecciona usuario a modificar
  114. $result = mysql_query("SELECT * FROM usuarios WHERE num_unico=".$_POST["usuario"]);
  115. if (mysql_num_rows($result)>0){
  #2 (permalink)  
Antiguo 11/05/2015, 09:26
 
Fecha de Ingreso: abril-2015
Ubicación: Santiago de Chile
Mensajes: 80
Antigüedad: 8 años, 11 meses
Puntos: 0
Respuesta: Problemas al ingresar datos a la base de datos

Esta es la segunta parte del programa:

Código PHP:
Ver original
  1. $num_unico=mysql_result($result,0, "num_unico");
  2.     $nombre_largo=mysql_result($result,0, "Nombre_largo");
  3.     $sucursal=mysql_result($result,0, "Sucursal");
  4.     $c_usados=mysql_result($result,0,"c_usados");
  5.     $c_ford_nuevos=mysql_result($result,0,"c_ford_nuevos");
  6.     $hyundai=mysql_result($result,0,"Hyundai");
  7.     $global=mysql_result($result,0,"Global");
  8.     $u_livianos=mysql_result($result,0,"u_livianos");
  9.     $ford_livianos=mysql_result($result,0,"ford_livianos");
  10.     $fortaleza=mysql_result($result,0,"fortaleza");
  11.     $fortaleza_camiones=mysql_result($result,0,"fortaleza_camiones");
  12.     $motos=mysql_result($result,0,"Motos");
  13.     $rentacar=mysql_result($result,0,"rentacar");
  14.     $agricola=mysql_result($result,0,"agricola");
  15.     $sin_area=mysql_result($result,0,"sin_area");
  16.     $nombre_user=mysql_result($result,0, "Nombre_Usuario");
  17.     $pass=mysql_result($result,0, "Clave_ing");
  18.     $nivel=mysql_result($result,0, "Nivel");
  19.     $cargo=mysql_result($result,0, "cargo_coti");
  20.     $celular=mysql_result($result,0, "celular_coti");
  21.     $email=mysql_result($result,0, "email");
  22.     $num_unico=mysql_result($result,0, "num_unico");
  23.     $fono_fijo=mysql_result($result,0, "Fono_Fijo");
  24. }
  25. echo("<br>");
  26. echo("<input type=hidden value=".$_POST["usuario"]." name=num_actual>");
  27. echo("<table border=1 width=100%>");
  28. echo("<tr>");
  29. echo("</tr>");
  30. echo("<td colspan='2' bgcolor='#00FFFF'><span class='Estilo1 Estilo6'>Datos de Usuario</span></td>");
  31. echo("</tr>");
  32. echo $num_unico;
  33. echo("<table border=1 width=100%>");
  34. echo("<tr>");
  35. echo("</tr>");
  36. echo("  <td>Nombre Completo</td>");
  37. echo("  <td><input type=text value=".chr(34).$nombre_largo.chr(34)." name=nombre_largo size=20 maxlength=20 onkeypress=".chr(34)."return tabular(event,this)".chr(34)."></td>");
  38. echo("</tr>");
  39. echo("<tr>");
  40. echo("  <td>Sucursal</td>");
  41. echo("  <td>");
  42. echo("  <select name=sucursal onkeypress=".chr(34)."return tabular(event,this)".chr(34).">");
  43. $result = mysql_query("SELECT * FROM mae_ubicaciones WHERE sucursal ='S' order by Ubicacion");
  44. if (mysql_num_rows($result)>0){
  45.    $i=0;
  46.    $rows=mysql_num_rows($result);
  47.    while($i < $rows) {
  48.       if ($sucursal==mysql_result($result, $i, "Ubicacion")){
  49.         echo("<option selected value=".chr(34).mysql_result($result, $i, "Ubicacion").chr(34).">".mysql_result($result, $i, "Ubicacion")."</option>");
  50.         }else{
  51.         echo("<option value=".chr(34).mysql_result($result, $i, "Ubicacion").chr(34).">".mysql_result($result, $i, "Ubicacion")."</option>");
  52.         }
  53.    $i++;
  54.    }
  55. }
  56. echo("</select>");
  57. echo("  </td>");
  58. echo("</tr>");
  59. echo("<tr>");
  60. echo("  <td>Contrase&ntilde;a</td>");
  61. echo("  <td><input type=text value=".chr(34).$pass.chr(34)." name=clave size=10 maxlength=10 onkeypress=".chr(34)."return tabular(event,this)".chr(34)."></td>");
  62. echo("</tr>");
  63. echo("<tr>");
  64. echo("  <td>Area de trabajo (Marcada con ''X'')</td>");
  65. echo("  <td>Camiones Usados      <input type=text value=".chr(3).$c_usados.chr(3)." name=c_usados size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  66. echo("</tr>");
  67. echo("<tr>");
  68. echo("  <td></td>");
  69. echo("  <td>Camiones Ford Nuevos <input type=text value=".chr(3).$c_ford_nuevos.chr(3)." name=c_ford_nuevos size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  70. echo("</tr>");
  71. echo("  <td></td>");
  72. echo("  <td>Hyundai              <input type=text value=".chr(3).$Hyundai.chr(3)." name=Hyundai size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  73. echo("</tr>");
  74. echo("  <td></td>");
  75. echo("  <td>Global               <input type=text value=".chr(3).$global.chr(3)." name=global size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  76. echo("</tr>");
  77. echo("  <td></td>");
  78. echo("  <td>Utilitarios Livianos <input type=text value=".chr(3).$u_livianos.chr(3)." name=u_livianos size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  79. echo("</tr>");
  80. echo("  <td></td>");
  81. echo("  <td>Ford Livianos        <input type=text value=".chr(3).$ford_livianos.chr(3)." name=ford_livianos size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  82. echo("</tr>");
  83. echo("  <td></td>");
  84. echo("  <td>Fortaleza            <input type=text value=".chr(3).$fortaleza.chr(3)." name=Fortaleza size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  85. echo("</tr>");
  86. echo("  <td></td>");
  87. echo("  <td>Fortaleza Camiones   <input type=text value=".chr(3).$fortaleza_camiones.chr(3)." name=fortaleza_camiones size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  88. echo("</tr>");
  89. echo("  <td></td>");
  90. echo("  <td>Motos                <input type=text value=".chr(3).$motos.chr(3)." name=motos size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  91. echo("</tr>");
  92. echo("  <td></td>");
  93. echo("  <td>Rentacar             <input type=text value=".chr(3).$rentacar.chr(3)." name=Rentacar size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  94. echo("</tr>");
  95. echo("  <td></td>");
  96. echo("  <td>Agricola             <input type=text value=".chr(3).$agricola.chr(3)." name=agricola size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  97. echo("</tr>");
  98. echo("  <td></td>");
  99. echo("  <td>Sin Area             <input type=text value=".chr(3).$sin_area.chr(3)." name=sin_area size=1 maxlength=1 onkeypress=".chr(3)."return tabular(event,this)".chr(3)."></td>");
  100. echo("</tr>");
  101. echo("<tr>");
  102. echo("  <td>Fono</td>");
  103. echo("  <td><input type=text value=".chr(34).$fono_fijo.chr(34)."  name=fono_fijo size=12 maxlength=12 onkeypress=".chr(34)."return tabular(event,this)".chr(34)."></td>");
  104. echo("</tr>");
  105.  
  106. echo("<tr>");
  107. echo("  <td>Nivel</td>");
  108. echo("  <td>");
  109. echo("  <select name=nivel onkeypress=".chr(34)."return tabular(event,this)".chr(34).">");
  110. if ($nivel==3){echo("<option selected value=3>Vendedor</option>");}else{echo("<option value=3>Vendedor</option>");}
  111. if ($nivel==2){echo("<option selected value=2>Asistente</option>");}else{echo("<option value=2>Asistente</option>");}
  112. if ($nivel==1){echo("<option selected value=1>Administrador</option>");}else{echo("<option value=1>Administrador</option>");}
  113. echo("</select>");
  114. echo("  </td>");
  115. echo("</tr>");
  116. echo("<tr>");
  #3 (permalink)  
Antiguo 11/05/2015, 09:28
 
Fecha de Ingreso: abril-2015
Ubicación: Santiago de Chile
Mensajes: 80
Antigüedad: 8 años, 11 meses
Puntos: 0
Respuesta: Problemas al ingresar datos a la base de datos

Esta es la tercera parte, el archivo guardar va en otro mensaje:

Código PHP:
Ver original
  1. echo("  <td>Cargo</td>");
  2. echo("  <td><input type=text value=".chr(34).$cargo.chr(34)."  name=cargo size=30 maxlength=40 onkeypress=".chr(34)."return tabular(event,this)".chr(34)."></td>");
  3. echo("</tr>");
  4. echo("<tr>");
  5. echo("  <td>Celular</td>");
  6. echo("  <td><input type=text value=".chr(34).$celular.chr(34)."  name=celular size=12 maxlength=12 onkeypress=".chr(34)."return tabular(event,this)".chr(34)."></td>");
  7. echo("</tr>");
  8.  
  9. $busqueda = 0;
  10. $cont=1;
  11. $busqueda = mysql_query("SELECT * FROM equipos_computacionales");
  12. $Total=mysql_num_rows($busqueda);
  13. if (($busqueda)>0){
  14.     echo "ingresa aca";
  15.     $ini=($Total+1);
  16.    
  17. }
  18. if ($Total==0){
  19.    echo "No encuentra registro";
  20.    $ini=($Total+1);
  21. }
  22. ?>
  23. <form action="grabar.php"method="POST" name="form3">
  24. <?
  25. echo("<table border=1 width=100%>");
  26. echo("<br>");
  27. echo("<tr>");
  28. echo("<td colspan='2' bgcolor='#00FFFF'><span class='Estilo1 Estilo6'>Claves del Sistema</span></td>");
  29. echo("</tr>");
  30. echo("<table border=1 width=100%>");
  31. echo("<tr>");
  32. echo("</tr>");
  33. echo("  <td>e-Mail</td>");
  34. echo("  <td><input type=text name=email size=20 maxlength=20 onkeypress=".chr(34)."return tabular(event,this)".chr(34)."></td>");
  35. echo("</tr>");
  36. echo("  <td>Clave Correo</td>");
  37. echo(" <td><input type=text name=clave_correo size=30 maxlength=40 onkeypress=".chr(34)."return tabular(event,this)".chr(34)."></td>");
  38. echo("</tr>");
  39. echo("</table>");
  40.  
  41. echo("</tr>");
  42. echo("<table border=1 width=100%>");
  43. echo("<br>");
  44. echo("<tr>");
  45. echo("<td colspan='2' bgcolor='#00FFFF'><span class='Estilo1 Estilo6'>Plataforma</span></td>");
  46. echo("</tr>");
  47.  
  48. echo("<table border=1 width=100%>");
  49. echo("<tr>");
  50. echo("</tr>");
  51. echo("<tr>");
  52. echo("<td>Nombre de Usuario</td>");
  53. echo("  <td><input type=text name=nombre size=12 maxlength=12 onkeypress=".chr(34)."return tabular(event,this)".chr(34)."></td>");
  54. echo("</tr>");
  55. echo("<tr>");
  56. echo("  <td>Contraseña</td>");
  57. echo("  <td><input type=text name=contrasena size=12 maxlength=12 onkeypress=".chr(34)."return tabular(event,this)".chr(34)."></td>");
  58. echo("</tr>");
  59. echo("<tr>");
  60. echo("  <td>Numero Unico</td>");
  61. echo(" <td><input type=text name=num_unico size=30 maxlength=40 onkeypress=".chr(10)."return tabular(event,this)".chr(10)."></td>");
  62. echo("</tr>");
  63. echo("</table>");
  64.  
  65. echo("</tr>");
  66. echo("<table border=1 width=100%>");
  67. echo("<br>");
  68. echo("<tr>");
  69. echo("<td colspan='2' bgcolor='#00FFFF'><span class='Estilo1 Estilo6'>Equipos</span></td>");
  70. echo("</tr>");
  71.  
  72. echo("<table border=1 width=100%>");
  73. echo("<tr>");
  74. echo("</tr>");
  75. echo("<tr>");
  76. echo("<td>Seleccione el Tipo de Equipo</td>");
  77. echo("<td>");
  78. ?> <select name="$tipo_equipo" size="1">
  79. <option value="PC" selected>PC</option>
  80. <option value="NOTEBOOK">Notebook</option>
  81. <option value="PANTALLA">Pantalla</option>
  82. </select>
  83. <?
  84. echo("</td>");
  85. echo("<tr>");
  86. echo("<tr>");
  87. echo("  <td>IP</td>");
  88. echo(" <td><input type=text name=ip_equipo size=15 maxlength=15 onkeypress=".chr(15)."return tabular(event,this)".chr(15)."></td>");
  89. echo("</tr>");
  90. echo("<tr>");
  91. echo("<tr>");
  92. echo("  <td>Propiedad de:</td>");
  93. echo("<td>");
  94. ?> <select name="$propiedad" size="1">
  95. <option value="Curifor" selected>Curifor</option>
  96. <option value="Personal">Personal</option>
  97. </select>
  98. <?
  99. echo("</td>");
  100.  
  101. echo("<tr>");
  102. echo("  <td valign='top'>Detalles</td>");
  103. echo(" <td> "); ?>
  104. <textarea name="$detalle" rows="100" cols="100" enabled>
  105. </textarea>
  106. <? echo "</td>";
  107. echo "</tr>";
  108. echo("</table>");
  109.  
  110. echo("<tr>");
  111. echo("<br>");
  112. echo("<table border=1 width=100%>");
  113. echo("<tr>");
  114. echo("<table border=1 width=100%>");
  115. }
  116. ?>
  117. <input type="submit" value="Guardar" onclick="location.href="grabar.php""">
  118. </form>
  119.  
  120. </form>
  121. </div>
  122. </body>
  123. </html>
  #4 (permalink)  
Antiguo 11/05/2015, 09:29
 
Fecha de Ingreso: abril-2015
Ubicación: Santiago de Chile
Mensajes: 80
Antigüedad: 8 años, 11 meses
Puntos: 0
Respuesta: Problemas al ingresar datos a la base de datos

Este es el archivo grabar:

Código PHP:
Ver original
  1. <?
  2. include "conectar.php";
  3. $ini=$_POST["ini"];
  4. $num_unico=$_POST["num_unico"];
  5. $nombre_usuario=$_POST["nombre_usuario"];
  6. $contrasena=$_POST["contrasena"];
  7. $tipo_equipo=$_POST["tipo_equipo"];
  8. $nombre=$_POST["ip_equipo"];
  9. $email=$_POST["email"];
  10. $clave_coreo=$_POST["clave_correo"];
  11. $detalle=$_POST["detalle"];
  12. echo $ini;
  13. echo $detalle;
  14. echo "<br\>";
  15. echo "<br\>";
  16. echo "<br\>";
  17. echo $num_unico;
  18. if (headers_sent()) {
  19.     // las cabeceras ya se han enviado, no intentar añadir una nueva
  20.     echo "cabeceras enviadas";
  21. }
  22. else {
  23.     echo "cabeceras no enviadas";
  24.     // es posible añadir nuevas cabeceras HTTP
  25. }
  26. $Sql="insert into equipos_computacionales (num_unico,nombre_usuario,contrasena,tipo_equipo,ip_equipo,email,clave_correo,detalle) values ('$num_unico','nombre_usuario','contrasena','tipo_equipo','ip_equipo','email','clave_correo','detalle')";
  27.  
  28.   echo "<h2>Thank you for your Comment!</h2>";
  29.  
  30. echo "Datos Ingresados Correctamente";
  31. ?>

Etiquetas: html, mysql, select, sql, usuarios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:49.