Ver Mensaje Individual
  #4 (permalink)  
Antiguo 10/02/2012, 12:26
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

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>