Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/08/2011, 08:22
Avatar de NewbPHP
NewbPHP
 
Fecha de Ingreso: agosto-2011
Ubicación: Las Garzas
Mensajes: 37
Antigüedad: 12 años, 8 meses
Puntos: 0
Información Problemas con Formulario

Buenos Dias Para Algunos y Buenas Tardes Para Otros ForerosdelWeb

He venido ante ustedes con una duda realizando mi pequeño sistema de Registro de reposos.

Resulta y acontece que el código abajo expuesto me esta dando un error y creo que es en el formulario en la parte de Action="reposos1.php" como saben php lee instruccion por instrucción linea por linea no soy muy experto en php, pero mis conocimientos ya no pueden resolver este problema el cual:

Es cuando le doy al boton Guardar el hace Submit pero no guarda nada me sale el mensaje de Javascript = Codigo no encontrado, el cual pueden ver abajo en el código que dice if filas = 0 no ejecuta la sentencia sql de INSERT INTO si no que va directo alli, he leido por hay que hay que hacer una interrupción y no se como y he venido aqui a ver si me ayudan.




Código PHP:
Ver original
  1. <?
  2.  
  3. if($_SESSION[nivel]=="0")
  4. {
  5.   echo "<div align=\"center\">";
  6.   echo "<img src=\"imagenes/denegado.png\" width=\"150\" height=\"180\" /><br />";
  7.   echo "<img src=\"imagenes/dened.png\" width=\"790\" height=\"206\" /><br />";
  8.   echo "</div>";
  9.   exit;
  10.  
  11. }
  12.  
  13. if(!isset($_SESSION[usuario]))
  14. {
  15.   ?>
  16.     <script type="text/javascript">
  17.       alert('Acceso no permitido');
  18.       top.location.href='index.php';
  19.     </script>
  20.   <?
  21. }
  22.  
  23. include("librerias/conexion.php");
  24. include("librerias/fecha.php");
  25. $conexion=conectar();
  26.  
  27. if(isset($_POST[codigo]))
  28. {
  29.  
  30.   $sql=mysql_query("INSERT INTO reposos SET (inicio_repo,duracion_repo,identifica_rep,dias,unidades) VALUES ('$_POST[inicio_repo]','$_POST[duracion_rep]','$_POST[identifica_rep]','$_POST[codigo]','$_POST[dias]','$_POST[unidades]')");
  31.   mysql_close($conexion);
  32.   ?>
  33.     <script type="text/javascript">
  34.     alert('Reposo Agregado con Exito');
  35.     location.href='inicio.php';
  36.     </script>
  37.   <?
  38.  
  39. }
  40.  
  41. $sql=mysql_query("SELECT * FROM registro WHERE codigo='$_GET[codigo]'");
  42. $filas=mysql_numrows($sql);
  43.  
  44. if($filas==0)
  45. {
  46.   ?>
  47.     <script type="text/javascript">
  48.     alert('Disculpe, codigo NO registrado');
  49.     location.href='reposos.php?codigo=<?echo $_GET[codigo]?>';
  50.     </script>
  51.   <?
  52. }
  53. ?>
  54.  
  55. <html xmlns="http://www.w3.org/1999/xhtml">
  56.  
  57. <head>
  58.   <title></title>
  59.   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  60.   <style>
  61.     .texto:focus
  62.     {
  63.       background-color :  #BDBDBD;
  64.     }
  65.   </style>
  66.   <style type="text/css">
  67.      table.tableizer-table {border: 1px solid #BDBDBD; font-family: Georgia, serif; font-size: 12px;} .tableizer-table td {padding: 4px; margin: 3px; border: 1px solid #BDBDBD;}
  68.   </style>
  69.  
  70. <script type="text/javascript" src="js/calendarDateInput.js"></script>
  71.  
  72. <script type="text/javascript">
  73.  
  74. function validar_datos()
  75. {
  76.     var F=document.formulario2;
  77.  
  78.         if(F.identifica_repo.value=="")
  79.     {
  80.         alert("Falta Ingresar Identificacion de Reposo");
  81.         F.identifica_repo.focus();
  82.         return false;
  83.     }
  84.     var r = confirm('¿Está seguro que desea crear este Reposo?');
  85.     if (r)
  86.     {
  87.       F.submit();
  88.     }
  89. }
  90. </script>
  91.  
  92. </head>
  93.  
  94. <body>
  95. <br><br><br><br>
  96.  
  97. <table width="80%" align="center" border="0" cellpadding="4" cellspacing="4"  class="tableizer-table">
  98.  <form name="formulario" action="#" method="post">
  99.   <tbody style="font-size : 12px;" bgcolor="#E6E6E6">
  100.     <tr>
  101.       <td colspan="2" align="center"  style="background-image: url(imagenes/fondo3.jpg); background-repeat: no-repeat" height="30"><strong>Registrar Reposos del Docente</strong></td>
  102.     </tr>
  103.     <tr>
  104.       <td width="160" align="right">Codigo:</td>
  105.       <td>
  106.         <?echo mysql_result($sql, 0, codigo)?>
  107.      </td>
  108.     </tr>
  109.     <tr>
  110.       <td align="right">Cedula</td>
  111.       <td>
  112.     <?echo mysql_result($sql, 0, cedula)?>
  113.     <input type="hidden" name="cedula" value="<?echo mysql_result($sql, 0, cedula)?>" />
  114.       </td>
  115.     </tr>
  116.      <tr>
  117.       <td align="right">Nombre y Apellido</td>
  118.       <td><?echo mysql_result($sql, 0, nombre_apellido)?></td>
  119.     </tr>
  120.     <tr>
  121.       <td align="right">Descripcion del Cargo:</td>
  122.       <td><?echo mysql_result($sql, 0, descripcion_cargo)?></td>
  123.     </tr>
  124.     <tr>
  125.       <td align="right">Fecha de Ingreso:</td>
  126.       <td><?echo fecha(mysql_result($sql, 0, f_ingreso))?></td>
  127.   </tbody>
  128.  </form>
  129. </table>
  130.  
  131. <br><br><br>
  132. <table width="600" align="center" border="0" cellpadding="4" cellspacing="4"  class="tableizer-table">
  133.  <form name="formulario2" action="reposos1.php" method="post">
  134.   <tbody style="font-size : 12px;" bgcolor="#E6E6E6">
  135.     <tr>
  136.       <td colspan="2" align="center" style="background-image: url(imagenes/fondo3.jpg); background-repeat: no-repeat" height="30"><strong>Registro de Reposos</strong></td>
  137.     </tr>
  138.     <tr>
  139.       <td width="160" align="right">Inicio de Reposo:</td>
  140.       <td><script>DateInput('f_ingreso', true, 'YYYY/MM/DD')</script></td>
  141.     </tr>
  142.     <tr>
  143.       <td align="right">Duracion del Reposo:</td>
  144.       <td><select name="dias">
  145.   <?
  146.   $i=1;
  147.  
  148. while($i<100)
  149. {
  150.  
  151. echo"<option value=\"$i\">$i</option>";
  152.  
  153. $i++;
  154. }
  155.   ?>
  156. </select>
  157. <select name="unidades">
  158. <option value="horas">Horas</option>
  159. <option value="dias">Dias</option>
  160. <option value="mes">Mes</option>
  161.  
  162. </select>
  163.  
  164. </td>
  165.     </tr>
  166.     <tr>
  167.       <td align="right">Identificacion del Reposo:</td>
  168.       <td><textarea name="identifica_repo" cols="53" class="texto"></textarea></td>
  169.     </tr>
  170.       <td colspan="2" align="center"><input type="button" name="guardar" value="Guardar" onclick="validar_datos()" /></td>
  171.     </tr>
  172.   </tbody>
  173.  </form>
  174. </table>
  175.  
  176. </body>
  177. </html>
  178. <script type="text/javascript">
  179.   document.formulario2.identifica_repo.focus();
  180. </script>

Aqui se llama a si mismo :
<form name="formulario2" action="reposos1.php" method="post">
pero no creo que sea el problema si no como interrumpir las otras funciones para que al darle clik en guardas ejecute INSERT INTO. Ya tengo una pagina reposos.php hace una búsqueda y me desplega a y reposos1.php Gracias