Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/03/2014, 12:11
keivis
 
Fecha de Ingreso: julio-2013
Mensajes: 123
Antigüedad: 10 años, 9 meses
Puntos: 1
error en variables php

hola como estan? tengo este codigo y tengo el siguiente error e intentado de todo y aun no lo soluciono. espero me puedan ayudad.

el error es el siguiente Undefined variable: post_usuario linea 259
Notice: Undefined variable: post_passwd linea 266

al realizar la busqueda de daton en la bd no me manda error alguno, pero cuando abro la interfaz principal me manda los errores en cuestión.

Código PHP:
Ver original
  1. <?php
  2. if (isset ($_SESSION['username'])){ } else{
  3. echo"<script language='JavaScript' type='text/JavaScript'> location.href='../../html/inicia_session.html'</script>";}?>
  4. <html>
  5. <head>
  6. <title></title>
  7. <link href="../css/estilo.css" rel="stylesheet" type="text/css">
  8. <script type="text/javascript" src="js/valform.js"> </script>
  9.  
  10. <style type="text/css">
  11. <!--
  12. .Estilo2 {color: #FF0000}
  13. -->
  14. </style>
  15.  
  16. <Script Language="JavaScript">
  17. <!--
  18. function mensaje()
  19. {
  20. window.alert("¡¡¡El Usuario ha sido Modificado Exitosamente!!!")
  21. }
  22.  
  23. function mensaje3()
  24. {
  25. window.alert("¡¡¡El Usuario ha sido Insertado Exitosamente!!!")
  26. }
  27.  
  28. function mensaje4()
  29. {
  30. window.alert("¡¡¡El Usuario ha sido Eliminado Exitosamente!!!")
  31. }
  32.  
  33. function mensaje2()
  34. {
  35. window.alert("¡¡¡ Debe LLenar todos los Campos !!!")
  36. }
  37. //-->
  38. </Script>
  39. </head>
  40.  
  41. <body onLoad="JavaScript: document.formul.nombre_autoridad.focus();">
  42.  
  43. <?php if (isset($_POST['insertar'])) { //+++++++++++++++++++++++++++++++++++++++++++++++++++++++
  44.  
  45. $post_usuario = strtoupper($_POST['usuario']);
  46. $post_passwd = $_POST['passwd'];
  47. $post_nombre_completo = strtoupper($_POST['nombre_completo']);
  48. $post_cedula = strtoupper($_POST['cedula']);
  49.  
  50. if ($_POST['usuario'] <> "" and $_POST['passwd'] <> "" and $_POST['nombre_completo'] <> "" and $_POST['cedula'] <> "") {
  51.  
  52.  
  53. include ("config.php");
  54. $con=mysql_connect($host,$user,$pass);
  55. if (!$con) {
  56. die('Problemas con el servidor: ' . mysql_error());
  57. }
  58. $db_selected = mysql_select_db($db,$con);
  59. if (!$db_selected) {
  60. die ('Error al conectar a la BD. : ' . mysql_error());
  61. }
  62. $consulta="insert into usuario (usuario, passwd, nombre_completo, cedula) values ('$post_usuario', '$post_passwd', '$post_nombre_completo', $post_cedula);";
  63. $query = mysql_query($consulta);
  64.  
  65. $post_usuario = "";
  66. $post_passwd = "";
  67. $post_nombre_completo = "";
  68. $post_cedula = ""; ?>
  69.  
  70. <Script Language="JavaScript"> mensaje3() </script>
  71.  
  72. <?php }
  73.  
  74. }//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++?>
  75.  
  76. <?php if (isset($_POST['modificar'])) { //******************************************
  77.  
  78. $post_usuario = strtoupper($_POST['usuario']);
  79. $post_passwd = $_POST['passwd'];
  80. $post_nombre_completo = strtoupper($_POST['nombre_completo']);
  81. $post_cedula = strtoupper($_POST['cedula']);
  82.  
  83. if ($_POST['usuario'] <> "" and $_POST['passwd'] <> "" and $_POST['nombre_completo'] <> "" and $_POST['cedula'] <> "") {
  84.  
  85.  
  86. include ("config.php");
  87. $con=mysql_connect($host,$user,$pass);
  88. if (!$con) {
  89. die('Problemas con el servidor: ' . mysql_error());
  90. }
  91. $db_selected = mysql_select_db($db,$con);
  92. if (!$db_selected) {
  93. die ('Error al conectar a la BD. : ' . mysql_error());
  94. }
  95. $consulta="update usuario set passwd = '$post_passwd', nombre_completo = '$post_nombre_completo', cedula = $post_cedula where usuario = '$post_usuario';";
  96. $query = mysql_query($consulta);
  97.  
  98. $post_usuario = "";
  99. $post_passwd = "";
  100. $post_nombre_completo = "";
  101. $post_cedula = ""; ?>
  102.  
  103. <Script Language="JavaScript"> mensaje() </script>
  104.  
  105. <?php }
  106.  
  107. }//*******************************************************************************?>
  108.  
  109.  
  110. <?php if (isset($_POST['eliminar'])) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  111.  
  112. $post_usuario = strtoupper($_POST['usuario']);
  113. $post_passwd = $_POST['passwd'];
  114. $post_nombre_completo = strtoupper($_POST['nombre_completo']);
  115. $post_cedula = strtoupper($_POST['cedula']);
  116.  
  117. if ($_POST['usuario'] <> "" and $_POST['nombre_completo'] <> "" and $_POST['cedula'] <> "") {
  118.  
  119.  
  120. include ("config.php");
  121. $con=mysql_connect($host,$user,$pass);
  122. if (!$con) {
  123. die('Problemas con el servidor: ' . mysql_error());
  124. }
  125. $db_selected = mysql_select_db($db,$con);
  126. if (!$db_selected) {
  127. die ('Error al conectar a la BD. : ' . mysql_error());
  128. }
  129. $consulta="delete from usuario where usuario = '$post_usuario';";
  130. $query = mysql_query($consulta);
  131.  
  132. $post_usuario = "";
  133. $post_passwd = "";
  134. $post_nombre_completo = "";
  135. $post_cedula = ""; ?>
  136.  
  137. <Script Language="JavaScript"> mensaje4() </script>
  138.  
  139. <?php }
  140.  
  141. }//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%?>
  142.  
  143.  
  144. <?php if (isset($_POST['buscar'])) { //------------------------------------
  145.  
  146. $post_usuario_bus = strtoupper($_POST['usuario_bus']);
  147.  
  148. include ("config.php");
  149. $con=mysql_connect($host,$user,$pass);
  150. if (!$con) {
  151. die('Problemas con el servidor: ' . mysql_error());
  152. }
  153. $db_selected = mysql_select_db($db,$con);
  154. if (!$db_selected) {
  155. die ('Error al conectar a la BD. : ' . mysql_error());
  156. }
  157. $consulta1 = "Select * from usuario where usuario = '$post_usuario_bus'";
  158. $resultado1 = mysql_query($consulta1, $con);
  159. $lafila1=mysql_fetch_array($resultado1);
  160.  
  161. $post_usuario = strtoupper($lafila1['usuario']);
  162. $post_passwd = $lafila1['passwd'];
  163. $post_nombre_completo = strtoupper($lafila1['nombre_completo']);
  164. $post_cedula = strtoupper($lafila1['cedula']);
  165.  
  166. }//-------------------------------------------------------------------- ?>
  167.  
  168. <form action="usuario.php" name="formul" method="post">
  169.  
  170. <script language="JavaScript">
  171.    var w = 400;
  172.    var h = 150;
  173.    resizeTo(w, h);
  174.    moveTo((screen.width - w)/ 2, (screen.height - h)/ 2);
  175.   </script>
  176.  
  177. <script language="JavaScript">
  178. <!--
  179.  
  180. function asignarfoco()
  181.  
  182. {
  183.    if (document.formul.nombre_autoridad.value.length==60)
  184.      {
  185.        document.formul.nombre_autoridad.focus();
  186.      }
  187. }
  188. -->
  189. </script>
  190.  
  191. <br>
  192. <br>
  193. <table width="80%" border="0" align="center" bordercolor="#0066FF" cellspacing="0" cellpadding="0">
  194.    <tr>
  195.     <td width="50%" bgcolor="#0066FF" align="left">
  196.      <br>
  197. <br>
  198. <center>
  199. <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  200.       <tr>
  201.         <td colspan="2" class="primeralinea"><font color="#FFFFFF">SELECCIONAR USUARIO</font></td>
  202.       </tr>
  203.     <tr>
  204.       <td>USUARIO:</td>
  205.     <td>
  206.         <select name="usuario_bus">
  207.           <option selected>
  208.           <?php
  209.         include ("config.php");
  210.         $con=mysql_connect($host,$user,$pass);
  211. if (!$con) {
  212. die('Problemas con el servidor: ' . mysql_error());
  213. }
  214. $db_selected = mysql_select_db($db,$con);
  215. if (!$db_selected) {
  216. die ('Error al conectar a la BD. : ' . mysql_error());
  217. }
  218.         $consulta3 = "Select usuario from usuario where usuario <> 'USUARIO'";
  219.         $resultado3 = mysql_query($consulta3, $con);
  220.         $lafila3=mysql_fetch_array($resultado3);
  221.         do
  222.           {
  223.            ?>
  224.              <option selected value="<?php echo $lafila3["usuario"] ?>"> <?php echo $lafila3["usuario"];         
  225.       } while ($lafila3=mysql_fetch_array($resultado3)); ?>
  226.         </select>
  227.         </font></td>
  228.     </tr>
  229. <tr align="center">
  230.      <td colspan="2" bgcolor="#0066FF">
  231.      <center>
  232.           <br>
  233.            <input name="buscar" type="submit" value="Buscar">
  234.            </center>
  235.      </td>
  236.  
  237. </tr>
  238. </table>
  239. <br>
  240. <br>
  241. <br>
  242. <br>
  243. <br>
  244. <table border="0" cellpadding="0" cellspacing="0" bordercolor="#0066FF">
  245.          
  246.             <tr>
  247.               <td colspan="2" align="center" class="primeralinea">
  248.                <center>
  249.                 <font color="#FFFFFF">USUARIO</font>
  250.                 </center>
  251.               </td>
  252.             </tr>        
  253.             <tr>
  254.               <td align="left">
  255.                 USUARIO:
  256.               </td>
  257.               <td align="left">
  258.                 <input type="text" name="usuario" size="45" maxlength="50" value = "<?php echo $post_usuario; ?>">
  259.               </td>  
  260.             </tr>
  261.             <tr>
  262.                
  263.             <td align="left"> CONTRASEÑA:</td>
  264.                <td align="left">
  265.                   <input name="passwd" type="text" size="45" maxlength="50" value = "<?php echo $post_passwd; ?>">
  266.                </td>
  267.             </tr>
  268.             <tr>
  269.               <td colspan="2" align="center">
  270.               </td>
  271.             </tr>
  272.  
  273.             <td align="left"> CEDULA:</td>
  274.                <td align="left">
  275.                   <input name="cedula" type="text" size="45" maxlength="50" onKeyPress="return ValidarNumero(event);" value = "<?php echo $post_cedula; ?>">
  276.                </td>
  277.             </tr>
  278.             <tr>
  279.               <td colspan="2" align="center">
  280.               </td>
  281.             </tr>
  282.             <td align="left"> NOMBRE Y APELLIDO:</td>
  283.                <td align="left">
  284.                   <input name="nombre_completo" type="text" size="45" maxlength="50" value = "<?php echo $post_nombre_completo; ?>">
  285.                </td>
  286.             </tr>
  287.             <tr>
  288.               <td colspan="2" align="center">
  289.               </td>
  290.             </tr>
  291.  
  292. <tr align="center">
  293.      <td colspan="2" bgcolor="#0066FF">
  294.      <center>
  295.           <br>
  296. <input type="submit" value="Insertar" name = "insertar">&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name = "modificar" value="Modificar">&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="Eliminar" name = "eliminar">
  297.       </center>
  298.      </td>
  299. </tr>
  300.  
  301. </table>
  302. <br>
  303. <br>
  304.  
  305. <td width="50%" align="center">
  306.  
  307. <div align="center" class="Estilo1">
  308.   <strong><img src="../imagenes/usuarios.jpg" alt="SISREG" width="400" height="400"></strong>
  309. </div>
  310.  
  311.  
  312. <br>
  313. </table>
  314. </form>  
  315. </body>
  316. </html>