Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 我想为codeigniter会话中的登录用户添加另一个表单_Mysql_Codeigniter_Session_Login - Fatal编程技术网

Mysql 我想为codeigniter会话中的登录用户添加另一个表单

Mysql 我想为codeigniter会话中的登录用户添加另一个表单,mysql,codeigniter,session,login,Mysql,Codeigniter,Session,Login,我有这个密码- if(isset($this->session->userdata['logged_in'])){ $this->load->view('admin_page'); } 现在我想添加新的形式,登录用户或管理员可以看到。但当我像下面这样添加表单控制器时,它不工作,也不将数据存储到数据库表中。该表是另一个单独的表,而不是用户表。因此,我在同一个模型文件中添加了两个独立的数据库详细信息,如下所示- <?php Class Login_D

我有这个密码-

  if(isset($this->session->userdata['logged_in'])){

  $this->load->view('admin_page');

  }
现在我想添加新的形式,登录用户或管理员可以看到。但当我像下面这样添加表单控制器时,它不工作,也不将数据存储到数据库表中。该表是另一个单独的表,而不是用户表。因此,我在同一个模型文件中添加了两个独立的数据库详细信息,如下所示-

<?php

Class Login_Database extends CI_Model {

function SaveForm($form_data)
{
    $this->db->insert('post', $form_data);

    if ($this->db->affected_rows() == '1')
    {
        return TRUE;
    }

    return FALSE;
 }

 // Insert registration data in database
 public function registration_insert($data) {

 // Query to check whether username already exist or not
 $condition = "username =" . "'" . $data['username'] . "'";
 $this->db->select('*');
 $this->db->from('users');
 $this->db->where($condition);
 $this->db->limit(1);
 $query = $this->db->get();
 if ($query->num_rows() == 0) {

 // Query to insert data in database
 $this->db->insert('users', $data);
 if ($this->db->affected_rows() > 0) {
 return true;
 }
 } else {
 return false;
 }
}

 // Read data using username and password
 public function login($data) {

 $condition = "username =" . "'" . $data['username'] . "' AND " . "password    
 =" . "'" . $data['password'] . "'";
  $this->db->select('*');
  $this->db->from('users');
  $this->db->where($condition);
 $this->db->limit(1);
 $query = $this->db->get();

 if ($query->num_rows() == 1) {
 return true;
 } else {
 return false;
  }
 }

 // Read data from database to show data in admin page
 public function read_user_information($username) {

 $condition = "username =" . "'" . $username . "'";
 $this->db->select('*');
 $this->db->from('users');
 $this->db->where($condition);
 $this->db->limit(1);
 $query = $this->db->get();

 if ($query->num_rows() == 1) {
 return $query->result();
 } else {
 return false;
 }
 }

 }

 ?>

到底是什么问题?您是否收到任何错误消息

如果问题是表单未显示,请确保会话设置正确

如果与表单未提交有关,请尝试回显$data的值,以确保其格式符合您的要求。请注意,它必须是key=>value对的数组,其中key是表列名,value是要插入的值

 if(isset($this->session->userdata['logged_in'])){

// My form for separate table goes here

 $this->load->view('admin_page');

}