PHP error, "Call to undefined function"

2

Hello, I'm new to PHP and am having the following error:

  

Call to undefined function PerformLogin ()

What can it be?

Code to call the function:

if(isset($_POST["btn-logar"]))
{
   include_once('../Controller/Login/Logar.php');

   RealizarLogin();
}

Function Code:

class Logar{

    var $usuario;
    var $senha;

    function RealizarLogin($usuario, $senha)
    {
        $this->$usuario = $_POST['usuario'];
        $this->$senha = $_POST['senha'];

        $login = $conn->prepare('SELECT count(1) as qtd FROM login WHERE usuario=:usuario AND senha=:senha');
        $login->bindParam(':usuario',$usuario);
        $login->bindParam(':senha',$senha);
        $login->execute();
        $retorno = $login->fetchAll();


        if($retorno[0]['qtd'] > 0)
        {
            session_start();
            $_SESSION['usuario'] = $usuario;
            $_SESSION['senha'] = $senha;

            print "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=../View/System/Home.php'>";
        } else {

            print "<meta HTTP-EQUIV='Refresh' CONTENT='0;URL=../View/Error/Error1.php'>";
        }
    }
    
asked by anonymous 19.12.2015 / 04:43

1 answer

5

A function is different from a method, it can not be invoked without the reference (object / class), to solve this create the object first and then call the method.

Your main file should be:

if(isset($_POST["btn-logar"]))
{
   include_once('../Controller/Login/Logar.php');
   $login = new Logar();
   $login->RealizarLogin();
}

The keyword var was used in php4 (legacy) to set a class's properties, from php5 to front use the access modifiers, public, protected, and private.

    
19.12.2015 / 04:59