Error Fatal error: Uncaught Error: Call to undefined function execute ()

1
  

Fatal error: Uncaught Error: Call to undefined function execute () in   D: \ xampp \ htdocs \ LOGIN \ validar.php: 14 Stack trace: # 0 {main} thrown in   D: \ xampp \ htdocs \ LOGIN \ validar.php on line 14

This is my code

<?php  session_start();

if(isset($_SESSION['usuario'])){
    header('Location: ../administrador/administrador.php');
}

if($_SERVER['REQUEST_METHOD']=='POST'){
    $usuario = $_POST["documento"];
    $contrasena = $_POST["contrasena"];

    require('conexion.php');

    $consulta = $conexion ->prepare('SELECT * FROM clientes WHERE documento=:usuario and contrasena=:contrasena');
    $consulta = execute(array(':usuario'=>$usuario,':contrasena'=>$contrasena));

    $resultado = $consulta ->fecth();
    if($resultado!==false){
        $_SESSION['usuario']=$usuario;
        header('Location: ../administrador/administrador.php');
    }else{
        header('Location: index.php');
    }
  }
 ?>
    
asked by Daniel Amaya 30.04.2018 в 03:19
source

1 answer

0

If you have already known the user and password bookmarks, you should only execute your query in this way:

$consulta = $conexion ->prepare(
                                'SELECT * FROM clientes 
                                 WHERE usuario = ? 
                                 AND contrasena = ?'
                                );
$consulta->bind_param('s', $usuario);
$consulta->bind_param('s', $contrasena);
$consulta->execute();
  

Where you can see is to access the execute() method, but not   indicate that your query is the same as that method

  

As you can also notice, you need to make the bind of each of   the values of your query and likewise indicate the data time, which   in this case it should be s of string

Also check if the document is the name of your column or maybe you were wrong and were a user and the bookmarks in mysqli should be with question marks

    
answered by 30.04.2018 в 04:30