Foros del Web » Programando para Internet » PHP »

enviar metodo $_GET por metodos $_POST

Estas en el tema de enviar metodo $_GET por metodos $_POST en el foro de PHP en Foros del Web. hola es que tengo un scrip donde todo es por metodo $_GET y lo ando cambiando a post y quiero enviar un Get por metodo ...
  #1 (permalink)  
Antiguo 10/02/2012, 12:16
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
enviar metodo $_GET por metodos $_POST

hola es que tengo un scrip donde todo es por metodo $_GET y lo ando cambiando a post y quiero enviar un Get por metodo post eso es posible
  #2 (permalink)  
Antiguo 10/02/2012, 12:17
Avatar de PIRRUMAN  
Fecha de Ingreso: febrero-2006
Ubicación: Monterrey, Nuevo León
Mensajes: 633
Antigüedad: 18 años, 2 meses
Puntos: 53
Respuesta: enviar metodo $_GET por metodos $_POST

dependiendo de como este tu codigo
puedes colocarlo para verlo
__________________
“Prefiero ser un tonto momentaneo que un eterno ignorante”
“¡El éxito es resultado de los aciertos,los aciertos resultado de la experiencia y la experiencia resultado de los errores!”
  #3 (permalink)  
Antiguo 10/02/2012, 12:18
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: enviar metodo $_GET por metodos $_POST

No estoy seguro de si es 100% posible, es muy probable que si.

Pero bueno, hasta que hagas la prueba vas a poder comprobarlo.

¿O exactamente que tipo de respuesta necesitas?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #4 (permalink)  
Antiguo 10/02/2012, 12:26
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: enviar metodo $_GET por metodos $_POST

el script trabaja por modulo y aqui le va

usuario.php

Código PHP:
Ver original
  1. <?php
  2.     $u = new usuarios();
  3.     if( isset( $_POST["nuevo"] ) )
  4.         require_once("vista_nuevo.php");
  5.     elseif( isset( $_GET["guardar"] ) || isset( $_POST["guardar_cambios"] ) )
  6.     {
  7.         $u->nombre = preparar( $_POST["nombre"] );
  8.         $u->comentarios = preparar( $_POST["comentarios"] );
  9.         $u->correo = preparar( $_POST["correo"] );
  10.         $u->usuario = preparar( $_POST["usuario"] );
  11.         $u->contrasena = preparar( $_POST["contrasena"] );
  12.         $u->creador = isset( $_POST["creador"] ) ? preparar($_POST['creador']) : '';
  13.         if( isset( $_GET["guardar"] ) )
  14.         {
  15.             $u->guardar();
  16.             $u->incrementar();
  17.         }else{
  18.             $u->id = $_POST["id"];
  19.             $u->fecha_vencimiento = preparar( $_POST["fecha_vencimiento"] );
  20.             $u->renovaciones = preparar( $_POST["renovaciones"] );
  21.             $u->profiles = preparar( $_POST["profiles"] );
  22.             $u->maxconnections = preparar( $_POST["maxconnections"] );
  23.             $u->guardar_cambios();
  24.         }
  25.     }elseif( isset( $_POST["eliminar"] ) )
  26.     {
  27.         $u = new general();
  28.         $u->id = preparar( $_POST["id"] );
  29.         $u->eliminar();
  30.         back();
  31.     }elseif( isset( $_POST["editar"] ) )
  32.     {
  33.         require_once("vista_editar.php");
  34.     }else{
  35.         $p = $_SESSION["posicion"];
  36.               if ( $p != USUARIO ) require_once("vista_listado.php");
  37.            }  
  38. ?>

vista_listado.php

Código PHP:
Ver original
  1. <div id="content">
  2. <table width="900">
  3.   <tr>
  4.     <td>
  5. <?php
  6.     // Mostrar el listado de mis  dealers
  7.     $u = new usuarios();
  8.     $listado = $u->listado();
  9.     $cuantos = $u->cuantos();
  10.     $de = $cuantos + $_SESSION['creditos_altas'];
  11.  
  12. if( $cuantos < $de || $_SESSION["posicion"] == ADMIN)
  13. {
  14. echo "<form name='form' id='form' enctype='multipart/form-data' method='post' action=''>";
  15. echo "<input type='hidden' name='nuevo' value='nuevo'>";
  16. echo "<a onClick=\"$('#form').submit();\" class=\"button\">[Nuevo]</a>";
  17.  
  18.     if( $_SESSION["posicion"] != ADMIN )
  19.     echo "&nbsp;| {$cuantos} de {$de} cr&eacute;ditos";
  20. echo "</form>";
  21. }
  22. ?>
  23. <script type="text/javascript"><!--
  24. $('#form input').keydown(function(e) {
  25.     if (e.keyCode == 13) {
  26.         $('#form').submit();
  27.     }
  28. });
  29. //--></script>
  30.  
  31. <?php
  32.  
  33.     if( $listado ){
  34. ?>
  35.     </td>
  36.   </tr>
  37. </table>
  38.     <table cellpadding="5" cellspacing="0" width="900" class="listado">
  39.         <thead>
  40.             <tr align="left">
  41.                 <th>
  42.                     USUARIOS:                </th>  
  43.                 <th>
  44.                     Vencimiento:                </th>    
  45.                 <th>
  46.                     Estado:                </th>
  47.                 <th>
  48.                     Editar:                </th>    
  49.                 <th>
  50.                     Eliminar:                </th>              
  51.             </tr>
  52.         </thead>
  53.         <tbody>
  54.         <?php while( $row = mysql_fetch_assoc( $listado ) ){?>
  55. <?php
  56.     if ($row["baniado"] == "1") {
  57.       $color = "<tr class=\"bann\" align=\"left\">";
  58.     }
  59.      elseif($row["fecha_vencimiento"] < date('Y-m-d')) {
  60.       $color = "<tr class=\"disabled\" align=\"left\">";
  61.     }
  62.     elseif ($row["baniado"] == "0") {
  63.       $color = "<tr class=\"odd\" align=\"left\">";
  64.     }
  65.     print("".$color."");
  66. ?> 
  67.                     <th>
  68.                         <?php echo $row["usuario"];?><br />
  69.                         <span><?php echo $row["nombre"];?></span>                    </th>
  70.                     <td>
  71.                         <?php echo $row["fecha_vencimiento"];?>                    </td>
  72.                     <td>
  73.       <?php
  74.         if ($row["status"] == "1") {
  75.         $enableline = "<center><font color=\"#006600\">Activo</font><br><button type=\"button\" onclick=\"location.href='includes/proceso_activar.php?id=".$row["id_usuario"]."&s=".$row["status"]."'\" title=\"Esta Activo (haga clic para desactivar)\">Cambiar</button></center>";
  76.         } else {
  77.         $enableline = "<center><font color=\"#FF0000\">Inactivo</font><br><button type=\"button\" onclick=\"location.href='includes/proceso_activar.php?id=".$row["id_usuario"]."&s=".$row["status"]."'\" title=\"Esta Inactivo (haga clic para Activarlo)\">Cambiar</button></center>";
  78.         }
  79.         if ($row["fecha_vencimiento"] <> "") {
  80.            if(strtotime($row["fecha_vencimiento"]) < strtotime(date('Y-m-d'))) {
  81.         $enableline = "<center>Vencido</center>";
  82.                 }
  83.         }
  84.         if ($row["baniado"] == "1" ) {
  85.         $enableline = "<center>Baneado</center>";
  86.         }
  87.             print("".$enableline."");
  88.  
  89.     ?>                  </td>
  90.                      <td>
  91. <form name="form1" id="form1" enctype="multipart/form-data" method="post" action="">
  92. <input type="hidden" name="editar" value="editar">
  93. <input type="hidden" name="id" id="id" value="<?php echo $row["id_usuario"]?>" />
  94. <a onClick="$('#form1').submit();" class="button"><img src="images/editar.png" width="20" height="20" alt="Editar"></a>
  95. </form>
  96. <script type="text/javascript"><!--
  97. $('#form input').keydown(function(e) {
  98.     if (e.keyCode == 13) {
  99.         $('#form1').submit();
  100.     }
  101. });
  102. //--></script>                    </td>
  103.                     <td>
  104. <form name="form2" id="form2" enctype="multipart/form-data" method="post" action="" onsubmit="return confirm('¿Realmente desea eliminar al usuario?');">
  105. <input type="hidden" name="eliminar" value="eliminar">
  106. <input type="hidden" name="id" value="<?php echo $row["id_usuario"]?>">
  107. <a onClick="$('#form2').submit()" class="button"><img src="images/eliminar.png" width="20" height="20" alt="Eliminar"></a>
  108. </form>
  109. <script type="text/javascript"><!--
  110. $('#form input').keydown(function(e) {
  111.     if (e.keyCode == 13) {
  112.         $('#form2').submit();
  113.     }
  114. });
  115. //--></script>                    </td>
  116.  
  117.     </tr>
  118.     <?php }?>
  119.         </tbody>
  120.     </table>
  121. <?php }else{?><br /><br />
  122.      <div class="msj_info">
  123.         No hay usuarios creados.
  124.      </div>
  125. <?php }?>
  126.      </div>
  #5 (permalink)  
Antiguo 10/02/2012, 12:27
(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
  #6 (permalink)  
Antiguo 10/02/2012, 12:28
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: enviar metodo $_GET por metodos $_POST

¿Y exactamente cual es la parte del problema?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #7 (permalink)  
Antiguo 10/02/2012, 12:30
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: enviar metodo $_GET por metodos $_POST

que ando cambiando todo por metodo post amigo y cuando doy a editar un usaurio habre el modulo de editar pero no salen los datos del usuario a editar sale el primer usuario del id
  #8 (permalink)  
Antiguo 10/02/2012, 12:37
Avatar de PIRRUMAN  
Fecha de Ingreso: febrero-2006
Ubicación: Monterrey, Nuevo León
Mensajes: 633
Antigüedad: 18 años, 2 meses
Puntos: 53
Respuesta: enviar metodo $_GET por metodos $_POST

para verificar que datos estan recibiendo puedes utilizar estas 7 lineas ANTES de la parte donde empiezas a manipular tus variables php(preferencia al inicio de tu archivo:

Cita:
<?php print "<br><--------><br>";
print "Mis Variables GET<br>";
print_r($_GET);
print "<br><br>";
print "Mis Variables POST<br>";
print_r($_POST);
print "<br><-------><br>"; ?>
con esto verificas que es lo que estas recibiendo
__________________
“Prefiero ser un tonto momentaneo que un eterno ignorante”
“¡El éxito es resultado de los aciertos,los aciertos resultado de la experiencia y la experiencia resultado de los errores!”

Etiquetas: metodo, metodos, post
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 16:55.