Send array, POST method

1

Dear colleagues, previously I sent my IDs by GET and it caused me problems because a user could change the data of another user simply by changing ID.

Now I have modified my code and I am sending my ID by hidden method POST. The code is as follows:

<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  } ?>     

This code generates a form for each line and complies with what I want to hide the ID so that they do not modify the data.

My question is: Is this option valid? Is there a better solution? How do you do?

It is worth mentioning that I work with the Codeigniter framework.

    
asked by Luis Vega 28.09.2017 в 18:35
source

0 answers