Php variable that comes from a form of another page not defined

1

I have a form that has the data of an account and a foreign pk: identification, then I send them to another page to make the insert but the variables do not arrive, isset tells me they are not defined

if(isset($_GET['identificacion'])){
    $identificacion = $_GET['identificacion'];

    echo "<div align='center'>";    
            echo "<form action='cuenta_ingresada.php' method='post'>";

            echo "<label for='identificacion'>Identificacion </label> &nbsp;";       
            echo "<input type='text' name='identificacion' disabled value='". $identificacion . "'><br>";

            echo "<label for='nro_cuenta'>Número de Cuenta </label> &nbsp;";       
            echo "<input type='text' name='nro_cuenta' ><br>";

            echo "<label for='fecha_apertura'>Fecha de Apertura </label> &nbsp;";        
            echo "<input type='text' name='fecha_apertura' ><br>";

            echo "<label for='sucursal_ciudad'>Sucursal Ciudad </label> &nbsp;";      
            echo "<input type='text' name='sucursal_ciudad' ><br>";

            echo "<label for='tipo'>Tipo </label> &nbsp;";      
            echo "<input type='text' name='tipo' ><br>";

            echo "<label for='saldo'>Saldo </label> &nbsp;";    
            echo "<input type='text' name='saldo' ><br>";


            echo "<div class='button'>";
            echo "<button type='submit' name='submit' value='actualizar'>Actualizar</button>";  
             //<button type="submit" name="submit">Guardar</button>     
            echo "</div>";
            echo "</form>"; 
            echo "</div>";  

And here they come

if(isset($_POST['identificacion']) &&
        isset($_POST['nro_cuenta']) &&
        isset($_POST['fecha_apertura']) && 
        isset($_POST['sucursal_ciudad']) && 
        isset($_POST['tipo']) && 
        isset($_POST['saldo']))
    {             
        $nro_cuenta = $_POST['nro_cuenta'];
        $fecha_apertura = $_POST['fecha_apertura'];
        $sucursal_ciudad = $_POST['sucursal_ciudad'];
        $tipo = $_POST['tipo'];
        $saldo = $_POST['saldo'];
        $identificacion = $_POST['identificacion'];         

        $insertar = "INSERT INTO tbl_cuentas (nro_cuenta, fecha_apertura, sucursal_ciudad, tipo, saldo, identificacion) VALUES ('$nro_cuenta', '$fecha_apertura', '$sucursal_ciudad', '$tipo', '$saldo', '$identificacion')";
    
asked by Jhon Hernández 08.06.2018 в 23:23
source

1 answer

0

The problem is that the inputs that are disabled are not transmitted by POST. A solution would be to add a hidden input that contains the same information like this:

echo "<label for='identificacion'>Identificacion </label> &nbsp;";       
echo "<input type='text' disabled value='". $identificacion . "'><br>";
echo "<input type='hidden' name='identificacion' value='". $identificacion . "'>;
    
answered by 08.06.2018 / 23:29
source