Hi Friends,
Good day!
I am asking for help.
I just started learning code igniter.
and have some source that I followed.
during the testing.
I encountered undefined variable
on the following.
please see below code
Quote:<?php
defined('BASEPATH') or exit('No Direct Script Access Allowed');
class Users_model extends CI_Model{
//Declares Private Variable
private $_userID;
private $_name;
private $_userName;
private $_email;
private $_password;
private $_status;
public function setUserID($userID) {
$this->$_userID = $userID;
}
public function setEmail($email) {
$this->$_email = $email;
}
public function setPassword($password) {
$this->$_password = $password;
}
public function getUserInfo(){
$this->db->select(array('u.user_id','u.uname','u.email'));
$this->db->from('user as u');
$this->db->where('u.user_id',$this->_userID);
$query = $this->db->get();
return $query->row_array();
}
function login(){
$this->db->select('user_id','name','email');
$this->db->from('user');
$this->db->where('email', $this->$_email);
$this->db->where('password', $this->$_password);
$this->db->limit(1);
$query = $this -> db ->get();
if($query ->num_rows() == 1){
return $query->result();
} else {
return false;
}
}
}
?>
also below is the error
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined variable: _email
Filename: models/Users_model.php
Line Number: 23
Backtrace:
File: D:\xampp\htdocs\webdev\msit\application\models\Users_model.php
Line: 23
Function: _error_handler
File: D:\xampp\htdocs\webdev\msit\application\controllers\Users.php
Line: 65
Function: setEmail
File: D:\xampp\htdocs\webdev\msit\index.php
Line: 315
Function: require_once
I encountered undefined variable on the following
Message: Undefined variable: _email
Message: Undefined variable: _password
Message: Undefined property: Users::$users
and also
Message: Call to a member function login() on null
Thank you in advance