error "login" method using php and pdo object orientation [closed]

1

Good afternoon, I'm having trouble logging into my restricted page ...

SCREAM: Error suppression ignored for
( ! ) Fatal error: Call to a member function logar() on a non-object in C:\wamp\www\jauport\loginAdmin.php on line 85
Call Stack

I'm doing a login page in php using object orientation and I've done the method below to login to my bank and retrieve my saved information

public function logar($email, $senha)
    {

        try{
        $sel_usu = "SELECT * FROM usuario WHERE ema_usujauport = ? AND sen_usujauport = ? ";
        $sel_usu = $this->con->Connect()->prepare($sel_usu);
        $sel_usu->bindValue(1, $this->nome);
        $sel_usu->bindValue(2, $this->email);
        $sel_usu->execute();
        if($sel_usu->rowCount()==1):
           return  true;
        else:
           return false;
        endif;
        }
        catch(PDOException $erro_login){
        'erro'.$erro_login->getMessage();


        }

    }

Below I'm retrieving the value returned by my select

<?php



                if(isset($_POST['logar'])):
                   $login = new Usuario();

                   $email = $_POST['email'];
                   $senha = $_POST['senha'];

                   $login->setEmail($email);
                   $login->setSenha($senha);

                   $login = filter_input(INPUT_POST, "email", FILTER_SANITIZE_MAGIC_QUOTES);
                   $login = filter_input(INPUT_POST, "senha", FILTER_SANITIZE_MAGIC_QUOTES);



                   if($login->logar()):/*aqui ocorre o erro*/
                   header("location: restrito/index.php; ");

                   else:
                   echo 'Erro ao logar';
                   endif;
                endif;
                ?>
    
asked by anonymous 15.06.2017 / 20:23

1 answer

1

How it should be done: $login = new Usuario();

               $email =filter_input(INPUT_POST, "email", FILTER_SANITIZE_MAGIC_QUOTES);
               $senha =filter_input(INPUT_POST, "senha", FILTER_SANITIZE_MAGIC_QUOTES);

               $login->setEmail($email);
               $login->setSenha($senha);
           $login->logar();

Explaining what you did:
You have set a variable login (ok)
you replaced it by email and then by password overlay objects and did not put the objects in the correct places. (reason for the error)

    
15.06.2017 / 20:51