"login" method error using php and Pdo object orientation

Asked

Viewed 67 times

0

good afternoon, I am in error when 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 am making a login page in php using object orientation and I made the method below to log in to my database and retrieve my recorded 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 am recovering 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;
                ?>
  • In the previous lines you reset login I don’t know why.

1 answer

0


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 with email and then password override objects and did not place the objects in the correct locations. ( reason for error)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.