Welcome Guest, Not a member yet? Register   Sign In
Object : Class not found
#1

[eluser]TDSPower[/eluser]
Hello the CI'boyz,

I work on a project for my studies.

I have two classes :

Code:
class Visiteur extends Controller

Code:
require_once('visiteur.php');
class Membre extends Visiteur {
        public $id_membre;
        public $login;
        public $password;
        public $status;
        public $email;

I would like to create a Membre Object in the Visiteur class (when the visitor login).

So i put this :
Code:
$lemembre = new Membre();

And I have this error :
Quote:Fatal error: Class 'Membre' not found in Q:\wamp\www\deezer\system\application\controllers\visiteur.php on line 157

Thanks a lot,

François
#2

[eluser]nmweb[/eluser]
You did not include the membre file when you try to load its class.
#3

[eluser]TDSPower[/eluser]
I have done :
Code:
require_once('Membre.php');

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Membre::$Mvisiteur

Filename: libraries/Loader.php

Line Number: 980

Fatal error: Call to a member function _assign_libraries() on a non-object in Q:\wamp\www\deezer\system\libraries\Loader.php on line 980

The MVisiteur is my model for Visitor :
Code:
<?php

    class Mvisiteur extends Model {
        
        function Mvisiteur(){
            parent::Model();
        }...

Thanks a lot
#4

[eluser]TDSPower[/eluser]
I don't understand anything, please give me some help !
#5

[eluser]xwero[/eluser]
If the membre class extends the visiteur class why do you want to create a membre object in your visiteur class???
#6

[eluser]TDSPower[/eluser]
Cause the personn is a visitor when he surfs on my website... then he logins and become a Membre.

The easiest way is to put the login_function in the Membre class ?

Thanks for his fast answer !
#7

[eluser]xwero[/eluser]
the login function should be in the visiteur function because until the moment someone is logged in he is an unidentified visitor.
#8

[eluser]TDSPower[/eluser]
It is what I have done !

My login function verify login & password, if it's ok, i want to create an Membre Object to put it in my session... but the object creation is not ok...

Thanks
#9

[eluser]xwero[/eluser]
Can you show the code you use the classes in. It seems to me you have made some thinking errors.
#10

[eluser]TDSPower[/eluser]
Of course :

Membre.php
Code:
<?php

require_once('visiteur.php');
    
    class Membre extends Visiteur {
        
        public $id_membre;
        public $login;
        public $password;
        public $status;
        public $email;
        
        function Membre(){
            parent::Visiteur();
        }
        
        function index(){
            echo "Membre";
        }


        function creer_Playlist(String $nom, int $visibilite) {
            return $validite;
        }
        
...

        function creer_Historique(){
            return $validite;
        }
            

}
?>

Visiteur.php
Code:
<?php
    
    class Visiteur extends Controller {
        
        function Visiteur(){
            parent::Controller();
            $this->load->model('Mvisiteur');
            $this->load->helper(array('form', 'url'));
            $this->load->library('validation');
        }
        
        function index(){
            echo "Visiteur";
        }
        

            function ecouteur_extrait(int $id_musique){
                return $validite;
            }


            function rechercher_musique(string $titre, string $auteur, int $genre, int $annee, string $titre_album, int $duree, int $note){
                return $tableau_musique;
            }
            

                function form_inscription(){        
                        $rules['username'] = "trim|required|min_length[5]|max_length[20]";
                        $rules['password'] = "trim|required|min_length[5]|max_length[20]";
                        $rules['email'] = "required|valid_email|min_length[5]|max_length[40]";
                        $rules['visibilite'] = "callback_differentDeZero";
                        $this->validation->set_rules($rules);
                        
                        $fields['username']    = 'Nom dutilisateur';
                        $fields['password']    = 'Mot de passe';
                        $fields['email']    = 'Mail';
                        $fields['visibilite']    = 'Visibilité';
                        $this->validation->set_fields($fields);
                        
                        $data['VisibiliteProfil'] = $this->Mvisiteur->getVisibiliteProfil();
                        
                        if ($this->validation->run() == FALSE)
                        {
                            // "Erreur", on réaffiche le formulaire en indiquant les problèmes
                            $this->validation->error_string = "";
                            $this->load->view('form_inscription',$data);
                        }
                        else
                        {
                            if($this->Mvisiteur->verificationExistanceMembre()){
                                $this->Mvisiteur->insertUtilisateur();
                                $this->load->view('inscriptionReussie');
                            }
                            else{
                                $this->validation->error_string = "Utilisateur déjà enregistré (Login ou mail existant(s)).";
                                $this->load->view('form_inscription',$data);
                            }
                        }            
                }
            

            function differentDeZero($str){
                if (is_numeric($str) && ($str > 0)){
                    return TRUE;
                }
                else{
                    $this->validation->set_message('differentDeZero', 'Vous devez sélectionner une visibilité');
                    return FALSE;
                }
            }
            
            function inscription(string $login, string $email, string $password, int $statut){
                return $validite;
            }
            

            function form_connexion(){
                $rules['username'] = "trim|required|min_length[5]|max_length[20]";
                $rules['password'] = "trim|required|min_length[5]|max_length[20]|md5";
                $this->validation->set_rules($rules);

                $fields['username'] = 'Login';
                $fields['password'] = 'Mot de passe';
                $this->validation->set_fields($fields);

                
                if($this->validation->run() == FALSE){
                    // Erreur saisie formulaire
                    $this->validation->error_string = "";
                    $this->load->view('form_login');
                }
                else{    
                    if($this->Mvisiteur->verificationConnection()){
                        require_once('Membre.php');
                        $lemembre = new Membre();
                        
                        echo "ok";
                    }
                    else{
                        // Login & mot de passe non correspondant
                        $this->validation->error_string = "Erreur, ce couple login & mdp ne correspond pas.";
                        $this->load->view('form_login');
                    }  
                }          
            }
            

            function consulter_profil(int $id_membre){
                return $validite;
            }
    }
?>




Theme © iAndrew 2016 - Forum software by © MyBB