2
votes

This is my Model:

class Medecin_model extends CI_Model
{
    public $fillable = array('nom','prenom','genre','adresse','date_naissance','specialiter','servise','grade','etablissement','type_personne');
    public $id_medecin;
    public $nom;
    public $prenom;
    public $genre;
    public $adresse;
    public $date_naissance;
    public $specialiter;
    public $service;
    public $grade;
    public $etablissement;
    public $type_personne = Medecin;
    public function insert($nom, $prenom, $genre, $adresse, $date_naissance, $specialiter, $service, $grade, $etablissement)
    {
        $this->nom=$nom;
        $this->prenom=$prenom;
        $this->genre=$genre;
        $this->adresse=$adresse;
        $this->date_naissance=$date_naissance;
        $this->specialiter=$specialiter;
        $this->service=$service;
        $this->grade=$grade;
        $this->etablissement=$etablissement;
        // $this->db->insert('personne', $this);
    }

This is my controller:

defined('BASEPATH') OR exit('No direct script access allowed');

class Medecin extends CI_Controller
{

    public function index()
    {
        $this->load->view('header');
        $this->load->view('ajout_medecin');
        $this->load->view('footer');


    }
    public function ajout()
    {
        $this->load->model("Medecin_model");
        $nom=$this->input->post('first-name');
        $prenom=$this->input->post('last-name');
        $genre=$this->input->post('genre');
        $adresse=$this->input->post('adress');
        $date_naissance=$this->input->post('birthday');
        $specialiter=$this->input->post('speciality');
        $service=$this->input->post('service');
        $grade=$this->input->post('grade');
        $etablissement=$this->input->post('establishment');

        $doctor = new Medecin_model();
        $doctor->insert($nom, $prenom, $genre, $adresse, $date_naissance, $specialiter, $service, $grade, $etablissement);
    }

and i have this error message :

A PHP Error was encountered Severity: Notice Message: Use of undefined constant Medecin - assumed 'Medecin' Filename: core/Loader.php Line Number: 357 Backtrace: File: C:\wamp64\www\CodeIgniter\application\controllers\Medecin.php Line: 23 Function: model File: C:\wamp64\www\CodeIgniter\index.php Line: 315 Function: require_once

1
replace it public $type_personne = Medecin; with public $type_personne = 'Medecin'; - Pradeep
pls always response to the answers by giving some comments or ,if it helps you, by marking it as green and upvoting, it is the best way to thanks all the programmers - Pradeep

1 Answers

1
votes

Missing '' around Medecin

Replace it

public $type_personne = Medecin; 

With this

public $type_personne = 'Medecin';