Fatal error: Uncaught Error: Call to undefined method UserController

giuliano75

Nuovo Utente
12 Lug 2013
14
0
0
ho creato un login con delle classi pero mi da un errore

( ! ) Fatal error: Uncaught Error: Call to undefined method UserController::checkLogin() in C:\xampp\htdocs\progettoPersonale\controllers\UserController.php on line 17

( ! ) Error: Call to undefined method UserController::checkLogin() in C:\xampp\htdocs\progettoPersonale\controllers\UserController.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

le due classi sono :
PHP:
class UserController
{
    public $username = '';
    private $logged   = false;
    private $usermodel = '';

    public function __construct()
    {   $this->usermodel = new UserModel();
        session_start();
        

        if ($_SERVER['REQUEST_METHOD']=='POST' && isset($_GET['action'])&& $_GET['action']== 'login' ){
            $username = (isset($_POST['username']))? $_POST['username'] :false ;
            $password = (isset($_POST['password']))? $_POST['password'] :false ;
            var_dump($password,$username);
            if ($username !=false && $password !=false && $this->usermodel->checkLogin( $username, $password )){

                $this->username =$username ;
                $this->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'])&& $_GET['action']== 'logout'){
            unset($_SESSION['username']);
            unset($_SESSION['logged']);
            $_SESSION[ 'message' ] = 'Logout effettuato correttamente';
        }
        elseif (isset($_SESSION['username'])&& isset($_SESSION['logged'])){

            $this->username = $_SESSION['username'] ;
            $this->logged = true ;
        }
        $this->redirectToProperArea();
    }

class UserModel
{
    private $dbconn = null ;

    public function __construct()
    {
        $this->dbconn = new DbConnector();
    }


    public function checkLogin($username, $password ){

        $newpassword =password_hash($password, PASSWORD_DEFAULT);

        $res=$this->dbconn->select(
            array('id_utente'),
            'iscritti',
            'nome_utente='.$username.'&& password='.$newpassword

        );
        $num_rows=$this->dbconn->num_rows($res);
        if ($num_rows ==1){
            return true ;
        }else {
            return false ;
        }
    }
}
 
Ultima modifica di un moderatore:
Discussioni simili
Autore Titolo Forum Risposte Data
T [PHP] aiuto....Fatal error: Uncaught Error:non riesco a capire PHP 1
G Fatal error: Uncaught exception 'PDOException' PHP 12
U Campo vuoto data errore Fatal error: PHP 2
D [PHP] Fatal error: Class 'COM' not found in C:\..... PHP 6
C [PHP] Errore "Fatal error: Call to undefined function getTotalUsers()" PHP 2
J [PHP] Recoverable fatal error: PHP 4
J [PHP] fatal error PHP 1
C PHP errore Fatal Error: Allowed Memory Size of ... Bytes Exhausted PHP 7
U [PHP] Fatal error: Call to a member function Query() PHP 1
Antoyosh Fatal error con Wordpress WordPress 5
O Fatal error: Call to undefined function testNome() in C:\xampp\...\...\index.php on line 51 PHP 4
JackIlPazzo Fatal error: Call to a member function execute() on a non-object PHP 2
filippino Fatal error: Cannot redeclare (function) PHP 2
JackIlPazzo PHP: Fatal error: Call to a member function bind_param() on a non-object PHP 0
P Fatal error: Call to undefined method SMTP::setTimeout() PHP 4
C errore su wordpress _ fatal error PHP 1
S [RISOLTO] Fatal error in Upload Multiplo di immagini PHP 2
M fatal error: Call to undefined function gdrcd_filter() PHP 6
F Fatal error: t3import not found object Joomla 0
Mauro Guardiani Fatal error HTML e CSS 2
T Fatal error: Call to a member function show_crom() on a non-object PHP 1
T Fatal error: Cannot access empty property PHP 2
F Fatal error: Call to undefined function PHP 9
L Fatal error: Call to undefined method Paging::listaPagine() PHP 2
LaKanka Fatal error upload immagini PHP 19
L Fatal error: Call to undefined function virtual() in C:\Inetpub\wwwroot\... PHP 1
L Error Code: 1215. Cannot add foreign key constraint MySQL 3
M HTTP Status 500 - Internal Server Error. Java 0
A Uncaught Error: jQuery 1
F Uncaught (in promise) Error: 3000ms timeout exceeded Javascript 0
W ADODB.Recordset error '800a0bb9' Classic ASP 2
D error text in table HTML e CSS 11
W Microsoft OLE DB Provider for Visual FoxPro error '80040e14' Function name is missing ). Classic ASP 0
W Parse error: syntax error, unexpected '$result' (T_VARIABLE) PHP 4
W Errore di run-time di Microsoft VBScript error '800a0035' Impossibile trovare il file Classic ASP 0
G Upload file error Apache 0
A Server Apache immagine not found (ERROR 404) Apache 5
T MySQL ERROR 1064 MySQL 1
T [PHP] ...Parse error che non c'è... PHP 7
V [MySQL] You have an error in your SQL syntax MySQL 1
G PHPMailer: SMTP error Gmail PHP 8
G [WordPress] [PHP] Parse error: syntax error, unexpected '$x332cbce1' WordPress 2
I [PHP] Login Facebook SDK returned an error: No URL set! PHP 0
bubino8 [PHP] Query syntax error PHP 6
momeraths [WordPress] cURL error: problema aggiornamento/installazione plugin WordPress 4
A [PHP] FPDF error: Some data has already been output, can't send PDF file PHP 5
otto9due Error anomalo durante invio dati $.ajax Ajax 20
N [PHP] problema Parse error in file configurazione PHP 3
F Console Error jQuery 1
K [ASP] Errore: ADODB.Field error '800a0bcd' Classic ASP 1

Discussioni simili