title: Fatal error: Uncaught Error: Call to undefined method UserController
body: <p>I created a login with the classes but gives me an error</p>
  
  <blockquote>
    <p>( ! ) <strong>Fatal error</strong>: Uncaught Error: Call to undefined method
    UserController::checkLogin() in
    C:\xampp\htdocs\progettoPersonale\controllers\User Controller.php on
    line 17</p>
    
    <p>( ! ) <strong>Error</strong>: Call to undefined method UserController::checkLogin() in
    C:\xampp\htdocs\progettoPersonale\controllers\User Controller.php on
    line 17 Call Stack
    # Time Memory Function Location 1 0.0010 360312 {main}( ) ...\login.php:0 2 0.0030 384208 UserController->__construct( )
    ...\login.php:7</p>
  </blockquote>
  
  <p>the two classes are:</p>
  
  <pre><code>class UserController
  {
      public $username = '';
      private $logged   = false;
      private $usermodel = '';
  
      public function __construct()
      {   $this-&gt;usermodel = new UserModel();
          session_start();
  
  
          if ($_SERVER['REQUEST_METHOD']=='POST' &amp;&amp; isset($_GET['action'])&amp;&amp; $_GET['action']== 'login' ){
              $username = (isset($_POST['username']))? $_POST['username'] :false ;
              $password = (isset($_POST['password']))? $_POST['password'] :false ;
              var_dump($password,$username);
              if ($username !=false &amp;&amp; $password !=false &amp;&amp; $this-&gt;usermodel-&gt;checkLogin( $username, $password )){
  
                  $this-&gt;username =$username ;
                  $this-&gt;logged = true ;
  
                  $_SESSION['username']= $username ;
                  $_SESSION['logged']= true ;
                  $_SESSION[ 'message' ]  = 'Login effettuato correttamente';
              }else{
                  $_SESSION[ 'message' ]  = 'Errore con il login; riprovare!';
              }
          }
          elseif (isset($_GET['action'])&amp;&amp; $_GET['action']== 'logout'){
              unset($_SESSION['username']);
              unset($_SESSION['logged']);
              $_SESSION[ 'message' ] = 'Logout effettuato correttamente';
          }
          elseif (isset($_SESSION['username'])&amp;&amp; isset($_SESSION['logged'])){
  
              $this-&gt;username = $_SESSION['username'] ;
              $this-&gt;logged = true ;
          }
          $this-&gt;redirectToProperArea();
      }
  class UserModel
  {
      private $dbconn = null ;
  
      public function __construct()
      {
          $this-&gt;dbconn = new DbConnector();
      }
  
  
      public function checkLogin($username, $password ){
  
          $newpassword =password_hash($password, PASSWORD_DEFAULT);
  
          $res=$this-&gt;dbconn-&gt;select(
              array('id_utente'),
              'iscritti',
              'nome_utente='.$username.'&amp;&amp; password='.$newpassword
  
          );
          $num_rows=$this-&gt;dbconn-&gt;num_rows($res);
          if ($num_rows ==1){
              return true ;
          }else {
              return false ;
          }
      }
  }  
  </code></pre>