1

Estimados compañeros, anteriormente enviaba mis ID por GET y me a causado problemas ya que un usuario podia cambiar los datos de otro usuario simplemente cambiando de ID.

Ahora he modificado mi codigo y estoy enviando mis ID por hidden method POST. El codigo es el siguiente:

<table class="table table-bordered text-center">
    <thead>
            <tr style="background:#2980b9;color:white;">
            <th  class="text-center">#</th>
            <th class="text-center">FECHA DE INSCRIPCIÓN</th>
            <th class="text-center">CURSO INSCRITO</th>
            <th class="text-center">CONDICION</th>
            <th class="text-center">NRO INSCRITOS</th>
            <th class="text-center"><i class="fa fa-search" aria-hidden="true"></i></th>            
        </tr>
    </thead>        
    <?php $i=1; foreach ($data as $fila) { ?>   
    <form method="POST" action="<?= base_url()?>user_detalle/detalle">
    <tbody>
        <tr>
            <td><?php echo $i++; ?></td>        
            <td><?php echo date("d-m-Y", strtotime($fila->fec_cre)) ?></td>
            <td><?php echo fechaCastellano($fila->fec_ini) ?></td>             
            <?php
                if ($fila->est_ins == 0) {
                    echo '<td>Normal</td>';
                }elseif ($fila->est_ins == 1){
                    echo '<td>Anulado</td>';
                }else{
                    echo '<td>Reprogramado</td>';
                }
             ?>
            <td><?php echo $fila->num_ins ?></td>
            <td><?php if ($fila->est_ins == 1) { ?>
                <span class="text-danger">Anulado</span>
            <?php }else{ ?>
                <button type="submit" class="btn btn-info btn-sm">Detalle</button>
                <?php } ?>
            </td>           
        </tr>
            <input type="hidden" name="idinscripcion" value="<?php echo $fila->idinscripcion; ?>">
            <input type="hidden" name="idregistro" value="<?php echo $fila->idregistro; ?>">                      
    </tbody>
    </form>     
    <?php  } ?>     

Este código me genera por cada linea un form y cumple con lo que quiero que es ocultar el ID para que no modifiquen los datos.

Mi pregunta es: Esta opción es valida?, hay una solución mejor? como hacen ustedes?

Cabe mencionar que trabajo con el framework Codeigniter.

2
  • 1
    ¿Porqué metes una tabla dentro de un formulario? Si necesitas un formulario, usa un formulario.
    – Javi Ps
    el 28 sep. 2017 a las 17:32
  • Estuvo mal planteado la solucion, acabo de crear un controller que valide los datos por get si corresponden al usuario. Ahora ya esta funcioando Bien.
    – Luis Vega
    el 29 sep. 2017 a las 15:28

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.