php search

0

I want to do a search by cedula, and if it is found that I reton to an edit but if it is not found that I return the value to a register but it does not return anything to me

This is where I do the search

< form action="" method="POST">

< label>Cedula</label>

< input text="number" id="cedula" name="cedula" placeholder="Introduzca su Cedula ej: 12345678 o 01234567" pattern="[0-9]{8}" maxlength="8" class="form-control" required>

    < input type="hidden" name="enviar" value="si">
    < input type="submit" value="Buscar" class="btn btn-info">

< /form>

The controller

require_once('../modelo/modelobusqueda.php');

    $obj = new busqueda();
    if (isset($_POST['enviar']))
    {
        $value= $obj->busquedaexp();

    }

and here the model

require_once('conexion.php');

class busqueda
{

    private $conex;

    function __construct()
    {
        $this->conex = new conexion();
    }
    function busquedaexp()
    {
        $sql = "SELECT  id_exp, cedula, nombre, apellido, telefono, descripcion, direccion, fecha_nac, sexo, id_parroquia FROM 'expediente' WHERE cedula = ?";
        $obj=$this->conex->prepare($sql);
        $obj->execute(array($_POST['cedula']));
        $value = $obj->fetch();
        if ($value) {
            return $value;
        }
        else {
            header('Location: vistaregistrarpersona.php');
        }
    }
}

If I put a vardump if it shows the data when the cedula exists but when it does not show me an array (size = 0) empty

    
asked by Anibal Peña 16.05.2018 в 00:44
source

0 answers