Php Codeigniter中的变量问题
试图修复我在某些代码中遇到的错误 我试着编辑模型,但没有任何效果。还编辑了控制器,更新了数据库,并确保某些文件夹位于父目录中。正在尝试找出如何修复此错误。如果有人能帮忙,我们将不胜感激 视图:Php Codeigniter中的变量问题,php,codeigniter,Php,Codeigniter,试图修复我在某些代码中遇到的错误 我试着编辑模型,但没有任何效果。还编辑了控制器,更新了数据库,并确保某些文件夹位于父目录中。正在尝试找出如何修复此错误。如果有人能帮忙,我们将不胜感激 视图: /资产/图像/“alt=”用户配置文件图片“> 型号: <?php class User_model extends CI_Model { function __construct(){ parent::__construct();
/资产/图像/“alt=”用户配置文件图片“>
型号:
<?php
class User_model extends CI_Model {
function __construct(){
parent::__construct();
$this->user_id =isset($this->session->get_userdata()['user_details'][0]->id)?$this->session->get_userdata()['user_details'][0]->users_id:'1';
}
/**
* This function is used authenticate user at login
*/
function auth_user() {
$email = $this->input->post('email');
$password = $this->input->post('password');
$this->db->where("is_deleted='0' AND (name='$email' OR email='$email')");
$result = $this->db->get('users')->result();
if(!empty($result)){
if (password_verify($password, $result[0]->password)) {
if($result[0]->status != 'active') {
return 'not_varified';
}
return $result;
}
else {
return false;
}
} else {
return false;
}
}
/**
* This function is used to delete user
* @param: $id - id of user table
*/
function delete($id='') {
$this->db->where('users_id', $id);
$this->db->delete('users');
}
/**
* This function is used to load view of reset password and varify user too
*/
function mail_varify() {
$ucode = $this->input->get('code');
$this->db->select('email as e_mail');
$this->db->from('users');
$this->db->where('var_key',$ucode);
$query = $this->db->get('cultured_codeignite');
$result = $query->row();
if(!empty($result->e_mail)){
return $result->e_mail;
}else{
return false;
}
}
/**
* This function is used Reset password
*/
function ResetPpassword(){
$email = $this->input->post('email');
if($this->input->post('password_confirmation') == $this->input->post('password')){
$npass = password_hash($this->input->post('password'), PASSWORD_DEFAULT);
$data['password'] = $npass;
$data['var_key'] = '';
return $this->db->update('users',$data, "email = '$email'");
}
}
/**
* This function is used to select data form table
*/
function get_data_by($tableName='users', $value='', $colum='',$condition='') {
if((!empty($value)) && (!empty($colum))) {
$this->db->where($colum, $value);
}
$this->db->select('*');
$this->db->from($tableName);
$query = $this->db->get('cultured_codeignite');
return $query->result();
}
/**
* This function is used to check user is alredy exist or not
*/
function check_exists($table='', $colom='',$colomValue=''){
$this->db->where($colom, $colomValue);
$res = $this->db->get($table)->row();
if(!empty($res)){ return false;} else{ return true;}
}
/**
* This function is used to get users detail
*/
function get_users($userID = '') {
$this->db->where('is_deleted', '0');
if(isset($userID) && $userID !='') {
$this->db->where('users_id', $userID);
} else if($this->session->userdata('user_details')[0]->user_type == 'admin') {
$this->db->where('user_type', 'admin');
} else {
$this->db->where('users.users_id !=', '1');
}
$result = $this->db->get('users')->result();
return $result;
}
/**
* This function is used to get email template
*/
function get_template($code){
$this->db->where('code', $code);
return $this->db->get('templates')->row();
}
/**
* This function is used to Insert record in table
*/
public function insertRow($table, $data){
$this->db->insert($table, $data);
return $this->db->insert_id();
}
/**
* This function is used to Update record in table
*/
public function updateRow($table, $col, $colVal, $data) {
$this->db->where($col,$colVal);
$this->db->update($table,$data);
return true;
}
}
将控制器函数中的代码放入行号/home4/cultured/public\u html/application/controllers/Login.php行:47
将数据返回到视图时,用户数据数组应该在那里
如果它不在那里,您将得到错误
$data["user_data"] = ""; // Your user_data query result should be here
$this->load->view("profile", $data);
请将控制器代码(函数)放在代码中设置此变量的位置好吗?嘿,伙计们!!我试图添加控制器,但太长了,无法安装:(嘿,谢谢!!!我遵循了你的代码,但仍然出现以下错误:严重性:注意消息:正在尝试获取非对象的属性…..我觉得它没有连接到数据库,但无法确定连接到何处。
$data["user_data"] = ""; // Your user_data query result should be here
$this->load->view("profile", $data);