Error "Undefined property:" in php

1
  

(!) Notice: Undefined property: stdClass :: $ documentP in   C: \ wamp64 \ www \ mathematchy \ mathematchy \ controller \ logincontroller.php   online 48

I submit this error when I try to make another login on my page (localhost) .

This is my code:

public function profes(){


      foreach ($this->model->verificar_credencialesprofes($_REQUEST['documentoP'],$_REQUEST['contrasenaP']) as $key) {

      }

      if(($_POST['documentoP']==$key->documentoP)&&($_POST['contrasenaP']==$key->contrasenaP)){

        $nuevo=new security();
        $nuevo->profes($key->usuarioP,$key->documentoP);

        $_SESSION['nombre']=$key->usuarioP;

        /*header('location: http://localhost/iniciodesesion/?clase=admin&metodo=profes');
      */}
      /*else{
        echo "<script> alert('El usuario o la contraseña son incorrectas');window.history.go(-1);</script>";



      }*/


    }

PS: I have commented on the script to visualize the error. Use wamp and MySql. My project is managed by MVC.

    
asked by Sercroft1 30.03.2017 в 04:28
source

1 answer

1

The error may be because you are passing two variables to the profes function, but you have declared the function without variables.

public function profes(){

  profes($key->usuarioP,$key->documentoP);

}
  

(I would need to see line 48 of the logincontroller.php file)

    
answered by 06.04.2017 в 13:56