Ver Mensaje Individual
  #7 (permalink)  
Antiguo 12/12/2011, 16:42
privatefta
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: duda de como insertar datos de post en checkbox

este es el que tengo para guardar

Código PHP:
Ver original
  1. elseif( isset( $_GET["guardar"] ) || isset( $_GET["guardar_cambios"] ) )
  2.     {
  3.         $error = false;
  4.         $d->nombre = preparar( $_POST["nombre"] );
  5.         $d->comentarios = preparar( $_POST["comentarios"] );
  6.         $d->correo = preparar( $_POST["correo"] );
  7.         $d->usuario = preparar( $_POST["usuario"] );
  8.         $d->contrasena = preparar( $_POST["contrasena"] );
  9.         $d->creditos = preparar( $_POST["meses"] );
  10.         $d->creditos_altas = preparar( $_POST["altas"] );
  11.         $d->creditos_renovaciones = preparar( $_POST["renovaciones"] );
  12.         $d->creador = isset( $_POST["creador"] ) ? preparar($_POST['creador']) : '';
  13.         $d->seleccion = preparar($_POST["seleccion"]);
  14.          if( isset( $_GET["guardar"] ) )
  15.         {
  16.             if(  $_FILES["logotipo"]['type'] == 'image/jpeg' || empty(  $_FILES["logotipo"]["tmp_name"] ) )
  17.             {
  18.                 $d->guardar();
  19.                 $d->incrementar();
  20.             }
  21.         }else{
  22.             if(  $_FILES["logotipo"]['type'] == 'image/jpeg' || empty(  $_FILES["logotipo"]["tmp_name"] ) )
  23.             {
  24.                
  25.                 $d->creditos_ant = preparar( $_POST["creditos_ant"] );
  26.                 $d->creditos_altas_ant = preparar( $_POST["creditos_altas_ant"] );
  27.                 $d->creditos_renovaciones_ant = preparar( $_POST["creditos_renovaciones_ant"] );
  28.                 $d->id = preparar( $_GET["id"] );
  29.                 $d->fecha_inicio = preparar( $_POST["fecha_inicio"] );
  30.                 $d->guardar_cambios();
  31.             }else $error = true;
  32.         }
  33.         if( $error )
  34.         {
  35.             $_SESSION["msj"]["clase"] = 'msj_error';
  36.             $_SESSION["msj"]["texto"] = 'Extensión no válida.';
  37.             back();        
  38.         }

y este es el que tengo para llegar el formulario

Código PHP:
Ver original
  1. <?php
  2.     $d = new dealers();
  3.     $cuantos = $d->cuantos();
  4.     $de = $_SESSION['creditos_altas'];
  5.     if( $de!=0 || $_SESSION["posicion"] == ADMIN){?>
  6. <script type="text/javascript" src="includes/js/jquery.validate.js"></script>
  7. <script type="text/javascript">
  8. $(document).ready(function(){                  
  9.    $("#form1").validate({
  10.         rules: {
  11.             usuario:"required",
  12.             contrasena : "required",
  13.             ccontrasena:{
  14.                 required: true,
  15.                 equalTo: "#contrasena"
  16.             }
  17.            
  18.         },
  19.         messages: {
  20.             usuario:"El nombre de usuario es requerido",
  21.             contrasena: "La contrase&ntilde;a es requerida",
  22.             ccontrasena: "Las contrase&ntilde;as no coinciden"
  23.         }
  24.     });
  25.    $('#logotipo').change( function(){
  26.         var dato = $(this).val();
  27.         var ext = dato.substr(dato.length-3).toUpperCase();
  28.         if( ext != 'JPG' && ext !='JPEG' )
  29.         {
  30.             $('#elogotipo').show();
  31.             $(this).val('');
  32.            
  33.         }else{
  34.            
  35.             $('#elogotipo').hide();
  36.         }
  37.     });
  38.    $.checar  = function(){
  39.         var u = $('#usuario').val();
  40.         if( u!= '' )
  41.         {
  42.             $.get('modulos/superdealers/disponibilidad.php',{usuario:u},
  43.                 function( data )
  44.                 {
  45.                     if( data == '0' )
  46.                     {
  47.                        
  48.                         $('#disponibilidad').fadeIn().html("<div class='msj_error'><i>"+u+"</i> no esta disponible.</div>").delay(800).fadeOut("slow");
  49.                         $('#usuario').val('');
  50.                     }else
  51.                     {
  52.                         $('#disponibilidad').fadeIn().html("<div class='msj_exito'><i>"+u+"</i> esta disponible.</div>").delay(800).fadeOut("slow");
  53.                     }
  54.                 });
  55.         }
  56.     };
  57. });
  58. </script>
  59. <form name="form1" method="post" id="form1" action="?mod=dealers&guardar" enctype="multipart/form-data"  >
  60.     <table class="datos" cellpadding="5" cellspacing="0">
  61.         <tr>
  62.             <th>
  63.                 Nombre:
  64.             </th>
  65.             <td>
  66.                 <input name="nombre" id="nombre" type="text" maxlength="100" size="30" />
  67.             </td>
  68.         </tr>
  69.         <tr>
  70.             <th>
  71.                Comentarios:
  72.             </th>
  73.             <td>
  74.                <textarea name="comentarios" cols="24" rows="5"></textarea>
  75.             </td>
  76.         </tr>
  77.         <tr>
  78.             <th>
  79.                 Usuario: <span>*</span>
  80.             </th>
  81.             <td>
  82.                
  83.                 <input name="usuario" id="usuario" type="text" maxlength="100" size="30" onblur="$.checar();" autocomplete="off"  /><br />
  84.                 <div id="disponibilidad" style="display:none; width:210px;"></div>
  85.                 <a href="javascript:$.checar();" id="checar">[Checar disponibilidad]</a>
  86.             </td>
  87.         </tr>
  88.         <tr>
  89.             <th>
  90.                 Contrase&ntilde;a: <span>*</span>
  91.             </th>
  92.             <td>
  93.                 <input name="contrasena" id="contrasena" type="password" maxlength="100" size="30" autocomplete="off" />
  94.             </td>
  95.         </tr>
  96.          <tr>
  97.             <th>
  98.                 Confirmar Contrase&ntilde;a: <span>*</span>
  99.             </th>
  100.             <td>
  101.                 <input name="ccontrasena" id="ccontrasena" type="password" maxlength="100"  size="30" autocomplete="off" />
  102.             </td>
  103.         </tr>
  104.           <tr>
  105.             <th>
  106.                 Logotipo:
  107.             </th>
  108.             <td>
  109.                 <div id="logo">
  110.                     <input type="file" name="logotipo" id="logotipo" class="logo" />                
  111.                 </div>
  112.                 <span>Tama&ntilde;o esperado: 900x100px, Tipo de archivo: jpg</span>
  113.                 <label  style="display:none;" class="error" id="elogotipo">Extensi&oacute;n no v&aacute;lida</label>
  114.             </td>
  115.         </tr>
  116.         <?php
  117.             if( $_SESSION["posicion"] == ADMIN )
  118.             {
  119.                 echo "<tr>
  120.                         <th>Asignar superdealer:</th>
  121.                         <td>";
  122.                             general::select_dealers( NULL,3 );
  123.                 echo "  </td>
  124.                       </tr>";
  125.             }
  126.         ?>
  127.          <tr>
  128.             <th>
  129.                 Correo electr&oacute;nico:
  130.             </th>
  131.             <td>
  132.                 <input name="correo" id="correo" type="text" maxlength="100" size="30" />
  133.             </td>
  134.         </tr>
  135.          <tr>
  136.             <th>
  137.                 Cr&eacute;ditos:
  138.             </th>
  139.             <td>
  140.                 <?php echo $d->creditos( 'meses' );?>
  141.             </td>
  142.         </tr>
  143.         <tr>
  144.             <th>
  145.                 Cr&eacute;ditos Altas:
  146.             </th>
  147.             <td>
  148.                 <?php echo $d->creditos_altas('altas');?>
  149.             </td>
  150.         </tr>
  151.         <tr>
  152.             <th>
  153.                 Cr&eacute;ditos Renovaciones:
  154.             </th>
  155.             <td>
  156.                 <?php echo $d->creditos_renovaciones('renovaciones');?>
  157.             </td>
  158.         </tr>
  159.         <tr>
  160.             <th>
  161.              Servicio a Vender:
  162.             </th>
  163.             <td>
  164. 1 <input type="checkbox" name="seleccion"  value="1"/>
  165. 2  <input type="checkbox" name="seleccion"  value="2"/>
  166. 2 <input type="checkbox" name="seleccion"  value="3"/>
  167.             </td>
  168.         </tr>
  169.         <tr>
  170.             <td colspan="2">
  171.                 <input name="Aceptar" type="submit" value="Aceptar"/>
  172.             </td>
  173.         </tr>
  174.     </table>
  175. </form>
  176. <?php }else echo "<div class='msj_error'>No hay creditos disponibles.</div>";?>