Code Does not work [closed]

1

Good morning, I'm being attacked by the error:

Fatal error: Call to a member function checkLoginPora () on string in /home/u683427321/public_html/NIMnovu/php/logindeny.php on line 123

This same code is line 123 ...

  
  <div class="form">
<H3 style='padding:20px;  color:black; text-shadow:1px 1px 10px red; font-size:30px;'><img src='http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/256/Letter-D-icon.png' width='100' height='100' /><Br>DENY - EMAIL MARKETING BEM VINDO!</H3>
    <form class="login-form" action='logindeny.php' method='post'>
      <input type="text" name='usuario' placeholder="Usuário"/>
      <input type="password" name='senha' placeholder="Senha"/>
      <input type='submit' />

    </form>
  </div>
</div>
<?php

if(isset($_POST['usuario'])) {
        $usuario = $_POST['usuario'];
        $senha = $_POST['senha'];
$usuario->verificaLoginPora($u,$s);

}
?>

MY FUNCTION

public function verificaLoginPora($u,$s){
                $consulta = $this->pdo->query("select *from banner ");
        foreach($consulta->fetchAll() as $v) {
                $usuario = $v['usuario'];
                $senha = $v['senha'];
                if(($usuario == $u) && ($senha == $s)) {
                    header('location:emails.php');

                }
        }

}
    
asked by anonymous 02.01.2018 / 00:39

1 answer

0

I imagine you have a class similar to this:

class MinhaClasse{
    public function verificaLoginPora($u,$s){
                $consulta = $this->pdo->query("select *from banner ");
        foreach($consulta->fetchAll() as $v) {
                $usuario = $v['usuario'];
                $senha = $v['senha'];
                if(($usuario == $u) && ($senha == $s)) {
                    header('location:emails.php');

                }
        }

   }

}

Then you want to access the verificaLoginPora() function that belongs to my class. For this you need to do:

if(isset($_POST['usuario'])) {
        //ambos serão string, e não vão ter a função verificaLoginPora()
        $usuario = $_POST['usuario'];
        $senha = $_POST['senha'];

        //não faça isso. usuario e senha serão parametros, 
        //não são instancias
        //$usuario->verificaLoginPora($u,$s);

        //em vez disso faça algo parecido com isso
        //provalvelmente o construtor da sua classe precisará receber alguns
        //parametros, então adapte conforme sua necessidade
        $minhaclasse = new MinhaClasse();
        $minhaclasse->verificaLoginPora($usuario,$senha);
}
    
02.01.2018 / 00:52