TMessage:在null上调用成员函数CheckUser()

时间:2018-04-03 19:28:00

标签: php html codeigniter

控制器

<SetupScreen>:
name: "setupscreen"
orientation: 'vertical'
ScrollView:
    GridLayout:
        cols: 1
        size_hint_y: None
        height: self.minimum_height
        padding: dp(48)
        spacing: 25
        MDLabel:
            font_style: 'Title'
            theme_text_color: 'Primary'
            text: "Setup"
            halign: "center"
        Divider:
        MDLabel:
            font_style: 'Subhead'
            theme_text_color: 'Primary'
            text: "User & Allocation"
            halign: "center"
        MDTextField:
            id: username_input
            hint_text: "Name"
            helper_text: "Please enter your name here."
            required: True
            write_tab: False
            on_text_validate: annual_input.focus=True;
        MDTextField:
            id: annual_input
            hint_text: "Annual Leave Alowance"
            helper_text: "Enter the number of annual leave days you get (ie 30)"
            required: True
            write_tab: False
            on_text_validate: sick_input.focus=True;
        MDTextField:
            id: sick_input
            hint_text: "Sick Leave Alowance"
            helper_text: "Enter the number of sick leave days you get (ie 30)"
            required: True
            write_tab: False
            on_text_validate: special_input.focus=True;
        MDTextField:
            id: special_input
            hint_text: "Special Leave Alowance"
            helper_text: "Enter the number of special leave days you get (ie 30)"
            required: True
            write_tab: False
            on_text_validate: setup_confirm_button.focus=True;
        MDLabel:
            font_style: 'Subhead'
            theme_text_color: 'Primary'
            text: "Select Non Workdays"
            halign: "center"
        LabeledCheckBox:
            id: mon_chkbox
            label_text: "Monday"
        LabeledCheckBox:
            id: tue_chkbox
            label_text: "Tuesday"
        LabeledCheckBox:
            id: wed_chkbox
            label_text: "Wednesday"
        LabeledCheckBox:
            id: thu_chkbox
            label_text: "Thursday"
        LabeledCheckBox:
            id: fri_chkbox
            label_text: "Friday"
        LabeledCheckBox:
            id: sat_chkbox
            label_text: "Saturday"
        LabeledCheckBox:
            id: sun_chkbox
            label_text: "Sunday"
        MDRaisedButton:
            id: setup_confirm_button
            text: "Confirm"
            halign: "center"
            opposite_colors: True
            on_release: root.on_confirm(username_input.text, annual_input.text, sick_input.text, special_input.text)

<LabeledCheckBox>:
    cols: 2
    spacing: 50
    MDLabel:
        font_style: 'Body1'
        theme_text_color: 'Primary'
        text: root.label_text
        halign: "center"
    MDCheckbox:
        halign: "left"

模型

<?php
error_reporting(E_ALL ^ E_NOTICE);

  class Login extends CI_Controller {
     public function _construct()
     {
         parent::_construct();
         $this->load->model('MUser');
     }

         public function index()
         {
          if ($this->session->userdata('logged') == true ) {
            redirect('rental') ;           
          }else{
            $this->load->view('login');
          }
         }

             public function validasi()
              {
                $this->load->library('Form_validation');
                $this->form_validation->set_rules('username', 'Username', 'required');
                $this->form_validation->set_rules('password', 'Password', 'required');

                    if($this->form_validation->run() == true) {
                      $username = $this->input->post('username');
                       $password = $this->input->post('password');

                        if($this->MUser->CheckUser ($username,$password) == true) {
                          $data = array('username'=>$username, 'logged'=> true);
                          $this->session->set_userdata($data);
                            redirect('rental');

                        }else{
                          $this->session->set_flashdata('pesan', 'Username atau password anda salah');

                             redirect('Login');
                       }

                    } else {
                      $this->load->view('login');
                    }    
              }

              public function logout()
              {
                $this->session->session_destroy();
                redirect('Login', 'referesh');
              }
            }
  ?>

遇到未捕获的异常

输入:错误

消息:在null

上调用成员函数CheckUser()

文件名:C:\ xampp \ htdocs \ rental \ application \ controllers \ Login.php

行号:30

回溯:

文件:C:\ xampp \ htdocs \ rental \ index.php 行:315 功能:require_once

回答我的问题

1 个答案:

答案 0 :(得分:0)

还是错了兄弟

&#34;这个错误的第30行&#34;

public function CheckUser($ username,$ password){        $ query = $ this-&gt; db-&gt; get_where($ this-&gt; table,array(&#39; username&#39; =&gt; $ username,&#39; password&#39; =&gt; $ password ));           if($ query-&gt; num_rows()&gt; 0)           {              返回true;           } else {              返回false;