Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php页面重定向方法因路由错误而无法工作_Php_Mysql_Full Text Search_Require - Fatal编程技术网

php页面重定向方法因路由错误而无法工作

php页面重定向方法因路由错误而无法工作,php,mysql,full-text-search,require,Php,Mysql,Full Text Search,Require,当该方法尝试重定向到页面时,会出现以下错误 警告:需要一次(查看/客户/注册/登录):无法打开 流:中没有这样的文件或目录 第58行的C:\xampp\htdocs\mvc4\model\cliente.php 致命错误:require_once():无法打开所需文件 “view/cliente/registordos/”(包括_path='C:\xampp\php\PEAR')在 第58行的C:\xampp\htdocs\mvc4\model\cliente.php php项目具有mvc结

当该方法尝试重定向到页面时,会出现以下错误

警告:需要一次(查看/客户/注册/登录):无法打开 流:中没有这样的文件或目录 第58行的C:\xampp\htdocs\mvc4\model\cliente.php


致命错误:require_once():无法打开所需文件 “view/cliente/registordos/”(包括_path='C:\xampp\php\PEAR')在 第58行的C:\xampp\htdocs\mvc4\model\cliente.php

php项目具有mvc结构

这是控制器

 <?php

 include_once 'model/cliente.php';

 class clienteController {

 private $model;
 public $mensaje;

 public function __CONSTRUCT() {
    $this->model = new cliente();
 }

 public function Paginar() {
    require_once 'view/header.php';
    require_once 'view/cliente/cliente.php';
 }

 public function agregar() {
    $cliente = new cliente();

    if (isset($_REQUEST['id'])) {
        $cliente = $this->model->Obtener($_REQUEST['id']);
    }

    require_once 'view/header.php';
    require_once 'view/cliente/cliente-editar.php';
}

 public function buscar() {
    require_once 'view/header.php';
    require_once 'view/cliente/cliente.php';
    $cliente = new cliente();

    if (isset($_POST['Nombre'])) {
        $cliente = $this->model->Buscarme($_POST['Nombre']);
    }
 }

 public function redireccionar() {
    require_once 'view/header.php';
    require_once 'view/creditos/Resultado.php';
    if (isset($_POST['Nombre'])) {
        $cliente = $this->model->Resultador($_POST['Nombre']);
    }
 }

 public function listador() {
    require_once 'view/header.php';
    if ($_REQUEST['Nombre'] == "Ardila") {
        require_once 'view/cliente/apellidos/Ardila.php';
    }
    if ($_REQUEST['Nombre'] == "Mateus") {
        require_once 'view/cliente/apellidos/Mateus.php';
    }
 }

 public function Guardar() {
    require_once 'view/header.php';
    $cliente = new cliente();
    $tamaño=$_FILES['imagen']['size'];
    $tipo=$_FILES['imagen']['type'];
    if($tamaño <= 3000000){
        if($tipo=="image/jpeg"||$tipo=="image/jpg" || $tipo=="image/png" || $tipo=="image/gif"){
        $ruta = "view/cliente/imagenes/";
        opendir($ruta);

        $destino = $ruta . $_FILES['imagen']['name'];
        copy($_FILES['imagen']['tmp_name'], $destino);
        $cliente->id = $_REQUEST['id'];
        $cliente->dni = $_REQUEST['dni'];
        $cliente->Nombre = $_REQUEST['Nombre'];
        $cliente->Apellido = $_REQUEST['Apellido'];
        $cliente->Correo = $_REQUEST['Correo'];
        $cliente->telefono = $_REQUEST['telefono'];
        $cliente->imagen = $_FILES['imagen']['name'];

        if ($cliente->id > 0) {
            $this->model->Actualizar($cliente);
        } else {
            $this->model->Registrar($cliente);
        }
        header('Location: index.php');
        }
        else{
        $this->mensaje="FORMATO NO ADMITIDO";
        require_once 'view/cliente/imagenes/error.php';
        }
    }
    else{
        $this->mensaje="TAMAÑO EXEDIDO";
        require_once 'view/cliente/imagenes/error.php';
    }

  }

  public function Eliminar() {
    $this->model->Eliminar($_REQUEST['id']);
    unlink($filename);
    header('Location: index.php');
  }

}

In-
public function Resultador($Nombre){..}
-
$pagina['Nombre']
为空。`but$pagina=$stm->fetch(PDO::fetch_ASSOC);为什么结果为空?检查您是否从
$\u POST['Nombre']
传递了正确的值
$Nombre
,既然$pagina['Nombre']不是空的,请在方法重定向$client=$this->model->result($REQUEST['Name'])中更改为client.controller;
<?php
class cliente
{
private $pdo;

public $id;
public $res;
public $resultado;
public $busqueda;
public $row;
public $dni;
public $Nombre;
public $Apellido;  
public $Correo;
public $Telefono;
public $imagen;

public function __CONSTRUCT()
{
    try
    {
        $this->pdo = conectar();     
    }
    catch(Exception $e)
    {
        die($e->getMessage());
    }
 }

 public function Listar()
 {
    try
    {
                $result = array();
                $stm = $this->pdo->prepare("SELECT * FROM cliente");
                $stm->execute();
                return $stm->fetchAll(PDO::FETCH_OBJ);
    }
    catch(Exception $e)
    {
        die($e->getMessage());
    }
  }

    public function Resultador($Nombre)
  {
    try {
                 $stm = $this->pdo->prepare("SELECT * FROM cliente WHERE Nombre = '$Nombre'");
                 $stm->execute();
                 $pagina=$stm->fetch(PDO::FETCH_ASSOC);
                 $ruta = "view/cliente/registrados/";
                 $resultado=$pagina['Nombre'];
                 $solucion = require_once ($ruta.$resultado);
                 return $solucion;
                } catch (Exception $ex) {
            die($e->getMessage());
        }
  }

    public function Buscarme($Nombre)
   {
        try {


         $stm = $this->pdo->prepare("SELECT * FROM cliente WHERE Nombre LIKE '%".$Nombre."%'");

         $stm -> execute(); 
         $res = $stm->fetchAll(PDO::FETCH_ASSOC); 
         $this->resultado= array();
         $i=0;
         foreach($res as $row){
            $this->resultado[$i]['id']       = $row['id'];
            $this->resultado[$i]['dni']      = $row['dni'];
            $this->resultado[$i]['Nombre']   = $row['Nombre'] ;
            $this->resultado[$i]['Apellido'] = $row['Apellido'];
            $this->resultado[$i]['Correo']   = $row['Correo'] ;
            $this->resultado[$i]['Telefono'] = $row['Telefono'] ;
            $this->resultado[$i]['Imagen'] = $row['Imagen'] ;
            $i++;
         }   

        } catch (Exception $ex) {
            die($e->getMessage());
        }
 }

   public function ListarApellido()
 {
    try
    {
                $result = array();
                $stm = $this->pdo->prepare("SELECT * FROM cliente WHERE Apellido = 'Ardila'");
                $stm->execute();
                return $stm->fetchAll(PDO::FETCH_OBJ);
    }
    catch(Exception $e)
    {
        die($e->getMessage());
    }
 }

    public function ListarApellidoM()
 {
    try
    {
                $result = array();
                $stm = $this->pdo->prepare("SELECT * FROM cliente WHERE Apellido = 'Mateus'");
                $stm->execute();
                return $stm->fetchAll(PDO::FETCH_OBJ);
    }
    catch(Exception $e)
    {
        die($e->getMessage());
    }
  }
  public function Obtener($id){
    try 
    {
    $stm = $this->pdo->prepare("SELECT * FROM cliente WHERE id = ?");
            $stm->execute(array($id));
            return $stm->fetch(PDO::FETCH_OBJ);
    } catch (Exception $e) 
    {
        die($e->getMessage());
    }
  }

public function Eliminar($id) {
    try {
        $ruta = "view/cliente/imagenes/";
        opendir($ruta);
        $stm = $this->pdo->prepare("SELECT Imagen FROM cliente WHERE id = ?");
        $stm->execute(array($id));
        $imgdel=$stm->fetch(PDO::FETCH_ASSOC);
        unlink($ruta.$imgdel['Imagen']);
        $stm = $this->pdo->prepare("DELETE FROM cliente WHERE id = ?");
        $stm->execute(array($id));
    } catch (Exception $e) {
        die($e->getMessage());
    }
  }

public function Actualizar(cliente $data)
{
    try 
    {
        $sql = "UPDATE cliente SET dni = ?, Nombre = ?, Apellido = ?, Correo = ?, Telefono = ?, Imagen = ? WHERE id = ?";
        $this->pdo->prepare($sql)->execute(array( $data->dni, 
                    $data->Nombre,$data->Apellido,$data->Correo,$data->telefono, $data->imagen, $data->id));
    } catch (Exception $e) 
    {
        die($e->getMessage());
    }
}

public function Registrar(cliente $data)
{
    try 
    {
    $sql = "INSERT INTO cliente (dni,Nombre,Apellido,Correo,telefono,Imagen) 
            VALUES (?, ?, ?, ?, ?, ?)";
    $this->pdo->prepare($sql)->execute(array($data->dni, $data->Nombre,$data->Apellido, $data->Correo, $data->telefono,$data->imagen)
    );
    } catch (Exception $e) 
    {
        die($e->getMessage());
    }
}
}
 <h1 class="page-header">CRUD con el patrón MVC en PHP POO y PDO </h1>
 <a class="btn btn-primary pull-right" href="?c=cliente&  a=agregar">Agregar</a>
 <a class="btn btn-primary pull-right" href="?c=cliente&a=listador&Nombre=Ardila">Ardila</a>
 <a class="btn btn-primary pull-right" href="?c=cliente&a=listador&Nombre=Mateus">Mateus</a>
 <br><br><br>
 <table class="table  table-striped  table-hover" id="tabla">
 <thead>
    <tr>
        <th style="width:180px; background-color: #5DACCD; color:#fff">ID</th>
        <th style="width:120px; background-color: #5DACCD; color:#fff">DNI</th>
        <th style="width:180px; background-color: #5DACCD; color:#fff">Nombre</th>
        <th style=" background-color: #5DACCD; color:#fff">Apellido</th>
        <th style=" background-color: #5DACCD; color:#fff">Correo</th>
        <th style="width:120px; background-color: #5DACCD; color:#fff">Telefono</th>
        <th style="width:60px; background-color: #5DACCD; color:#fff"></th>
        <th style="width:60px; background-color: #5DACCD; color:#fff"></th>
    </tr>
 </thead>
 <tbody>
    <?php foreach ($this->model->Listar() as $r): ?>
        <tr>
            <td><?php echo $r->id; ?></td>
            <td><?php echo $r->dni; ?></td>
            <td><?php echo $r->Nombre; ?></td>
            <td><?php echo $r->Apellido; ?></td>
            <td><?php echo $r->Correo; ?></td>
            <td><?php echo $r->Telefono; ?></td>
            <td>
                <a  class="btn btn-warning" href="?c=cliente&a=agregar&id=<?php echo $r->id; ?>">Editar</a>
            </td>
            <td>
                <a  class="btn btn-danger" onclick="javascript:return confirm('¿Seguro de eliminar este registro?');" href="?c=cliente&a=Eliminar&id=<?php echo $r->id; ?>">Eliminar</a>
            </td>

        </tr>
    <?php endforeach; ?>
 </tbody>
 </table>
 <form action="?c=cliente&a=buscar" method="post" >
 <input type="text" name="Nombre" id="Nombre"/>
 <input type="submit" name="boton" id="boton"/>
 </form>
<?php
$this->model->Buscarme(filter_input(INPUT_POST, "Nombre"));
$resultado = $this->model->resultado;
if ($_POST) {
$dni = $_POST['Nombre'];
try {
    foreach ($resultado as $f) {
        ?>

        <?php echo $f['id'] . '</br>'; ?>
        <?php echo $f['dni'] . '</br>'; ?>
        <?php echo '<a href="?c=cliente' . '&a=redireccionar&Nombre=' . urlencode($f['Nombre']) . '">' . $f['Nombre'] . '</a></br>'; ?>
        <?php echo $f['Apellido'] . '</br>'; ?>
        <?php echo $f['Correo'] . '</br>'; ?>
        <?php echo $f['Telefono'] . '</br>'; ?>
        <?php echo "<img  class='imagen' src=\"" . "view/cliente/imagenes/" . $f['Imagen'] . "\"/>"; ?>
        <?php
    }
} catch (PDOExecption $e) {
    echo $e->getMessage();
}
}
?>
</tbody>
</body>
<script  src="assets/js/datatable.js">
</script>
</html>