Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/02/2012, 12:27
privatefta
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: enviar metodo $_GET por metodos $_POST

y el del vista_editar.php

Código PHP:
Ver original
  1. <?php
  2.       $g = new general();
  3.       $g->posicion = 1;
  4.       $g->id = $_GET["id"];
  5.       $row = $g->editar();
  6.       if( $row ):
  7. ?>
  8. <script type="text/javascript" src="includes/js/jquery.validate.js"></script>
  9. <script type="text/javascript">
  10. var RegExPattern = /[^\w-.]/;
  11. $.validator.addMethod("alpha", function(value) {
  12.         var noValido = value.match(RegExPattern);
  13.         if( noValido )
  14.         {
  15.             return false;
  16.         }else{
  17.             return true;
  18.         }
  19. });
  20. $(document).ready(function(){                  
  21.  $("#form1").validate({
  22.         rules: {
  23.             nombre :{
  24.                 alpha:true
  25.             },
  26.             usuario :{
  27.                 required:true,
  28.                 alpha:true
  29.             },
  30.             contrasena :{
  31.                 required:true,
  32.                 alpha:true
  33.             },
  34.             ccontrasena:{
  35.                 required: true,
  36.                 equalTo: "#contrasena"
  37.             }
  38.            
  39.         },
  40.         messages: {
  41.             nombre:"El nombre admite solo letras y n&uacute;meros",
  42.             usuario:"El nombre de usuario admite solo letras y n&uacute;meros",
  43.             contrasena:"La contrase&ntilde;a admite solo letras y n&uacute;meros",
  44.             ccontrasena: "Las contrase&ntilde;as no coinciden"
  45.         }
  46.     });
  47.   $.esValido = function()
  48.    {
  49.        var noValido = $('#usuario').val().match(RegExPattern);
  50.         if( noValido )
  51.         {
  52.             return false;
  53.         }else{
  54.             return true;
  55.         }
  56.    }
  57.    
  58.  $.checar  = function(){
  59.       if( $.esValido() )
  60.        {
  61.             var u = $('#usuario').val();
  62.             if( u!= '' )
  63.             {
  64.                 $.get('modulos/superdealers/disponibilidad.php',{usuario:u},
  65.                     function( data )
  66.                     {
  67.                         if( data == '0' )
  68.                         {
  69.                            
  70.                             $('#disponibilidad').fadeIn().html("<div class='msj_error'><i>"+u+"</i> no esta disponible.</div>").delay(800).fadeOut("slow");
  71.                             $('#usuario').val('');
  72.                         }else
  73.                         {
  74.                             $('#disponibilidad').fadeIn().html("<div class='msj_exito'><i>"+u+"</i> esta disponible.</div>").delay(800).fadeOut("slow");
  75.                         }
  76.                     });
  77.             }
  78.        }
  79.     };
  80. });
  81. </script>
  82. <form name="form1" method="post" id="form1" action="" >
  83. <input type="hidden" name="guardar_cambios" value="guardar_cambios">
  84. <input type="hidden" name="id" value="<?php echo $row["id_usuario"]?>">
  85.     <table class="datos" cellpadding="5" cellspacing="0">
  86.         <tr>
  87.             <th>
  88.                 Nombre:
  89.             </th>
  90.             <td>
  91.                 <input name="nombre" id="nombre" type="text" maxlength="100" size="30" value="<?php echo $row["nombre"]?>" />
  92.             </td>
  93.         </tr>
  94.         <tr>
  95.             <th>
  96.                Comentarios:
  97.             </th>
  98.             <td>
  99.                <textarea name="comentarios" cols="24" rows="5"><?php echo $row["comentarios"]?></textarea>
  100.             </td>
  101.         </tr>
  102.         <tr>
  103.             <th>
  104.                 Usuario: <span>*</span>
  105.             </th>
  106.             <td>
  107.                
  108.                 <input name="usuario" id="usuario" type="text" maxlength="100" size="30" onblur="$.checar();"  autocomplete="off"  value="<?php echo $row["usuario"]?>" readonly/><br />
  109.                 <div id="disponibilidad" style="display:none; width:210px;"></div>
  110.                 <a href="javascript:$.checar();" id="checar">[Checar disponibilidad]</a>
  111.             </td>
  112.         </tr>
  113.         <tr>
  114.             <th>
  115.                 Contrase&ntilde;a: <span>*</span>
  116.             </th>
  117.             <td>
  118.                 <input name="contrasena" id="contrasena" type="text" maxlength="100" size="30" autocomplete="off"  value="<?php echo $row["contrasena"]?>" />
  119.             </td>
  120.         </tr>
  121.          <tr>
  122.             <th>
  123.                 Confirmar Contrase&ntilde;a: <span>*</span>
  124.             </th>
  125.             <td>
  126.                 <input name="ccontrasena" id="ccontrasena" type="password" maxlength="100"  size="30" autocomplete="off"  value="<?php echo $row["contrasena"]?>" />
  127.             </td>
  128.         </tr>
  129.          <tr>
  130.             <th>
  131.                 Correo electr&oacute;nico:
  132.             </th>
  133.             <td>
  134.                 <input name="correo" id="correo" type="text" maxlength="100" size="30"  value="<?php echo $row["correo"]?>"  />
  135.             </td>
  136.         </tr>
  137.         <?php if( isset( $_GET["d"] ) || $_SESSION["posicion"] == ADMIN ){?>
  138.                    <tr>
  139.                       <th>
  140.                             Cambiar de dealer:
  141.                       </th>
  142.                       <td>
  143.                         <?php
  144.                             $id = isset( $_GET["d"] ) ? $_GET["d"] : $row["creador"];
  145.                             general::select_dealers( preparar( $id ),2 );
  146.                         ?>
  147.                       </td>
  148.                    </tr>
  149.         <?php }?>
  150.                    <tr>
  151.                       <th>
  152.                             Servicio Asignado:
  153.                       </th>
  154.                       <td>
  155.                        <input name="profiles" id="profiles" type="text" maxlength="30" size="20" value="<?php echo $row["profiles"]?>" readonly />
  156.                       </td>
  157.                    </tr>
  158.                    <tr>
  159.                    <th> Max Conection:</th>
  160.                          <td>
  161.                             <input name="maxconnections" id="maxconnections" type="text" maxlength="5" size="5" value="<?php echo $row["maxconnections"]?>" readonly />            
  162.                          </td>
  163.                    </tr>
  164.          <tr>
  165.             <th>
  166.                Renovar:
  167.             </th>
  168.             <td>
  169.                 <?php echo $u->creditos_renovaciones( 'renovaciones' );?><br />
  170.                 Fecha de vencimiento: <?php echo $row["fecha_vencimiento"]?>
  171.             </td>
  172.         </tr>
  173.         <tr>
  174.             <td colspan="2">               
  175.                 <input name="fecha_vencimiento" type="hidden" value="<?php echo $row['fecha_vencimiento']?>" />
  176.                 <input name="Aceptar" type="submit" value="Guardar cambios"/>
  177.             </td>
  178.         </tr>
  179.     </table>
  180. </form>
  181. <?php else:?>
  182. <div class="msj_error">
  183.     No tienes permiso para editar este usuario.
  184. </div>
  185. <?php endif;?>

y este es el general.class.php

Código PHP:
Ver original
  1. <?php
  2.     /**
  3.      * Contiene las funciones generales
  4.      * del sistema
  5.      */
  6.      class general
  7.      {
  8.         /**
  9.          * Obtinee los datos del usuario
  10.          */
  11.          function editar()
  12.          {
  13.             $query = "SELECT *
  14.                       FROM usuarios
  15.                       WHERE id_usuario = {$this->id}
  16.                       AND posicion = {$this->posicion}";
  17.              
  18.             $result = mysql_query( $query );
  19.             if( $result )
  20.                 return mysql_fetch_assoc( $result );
  21.             return false;
  22.          }
  23.         /**
  24.          * Elimina un usuario
  25.          */
  26.          function eliminar()
  27.          {
  28.                   $query = "UPDATE usuarios
  29.                              SET eliminado = 1
  30.                        WHERE id_usuario = {$this->id}";
  31.              
  32.              $result = mysql_query( $query );
  33.              if( $result )
  34.              {
  35.                  $_SESSION["msj"]["clase"] = 'msj_exito';
  36.                  $_SESSION["msj"]["texto"] = 'La eliminacion ha sido exitosa.';
  37.              }
  38.          }
  39.        
  40.    
  41.      }
  42.  
  43. ?>


y me funciona si envia por get pero por metodo post no me busca el usuario