1

私はこれをしばらくの間行ってきましたが、役に立ちませんでした。codeigniter ブートストラップ ログインに問題があります。だから基本的にこれは私が持っているものです:

login.php - コントローラー

 <?php if (!defined('BASEPATH')) die();
 class Login extends Main_Controller {

 function __construct(){
    parent::__construct();
 }

 public function index()
 { 
  $this->load->view('include/header');
  $this->load->view('login_view');
  $this->load->view('include/footer');
 }

 public function process(){
    // Load the model
    $this->load->model('login_model');
    // Validate the user can login
    $result = $this->login_model->validate();
    // Now we verify the result
    if(! $result){
        // If user did not validate, then show them login page again
        $this->index();
    }else{
        // If user did validate, 
        // Send them to members area
        redirect('home');
    }        
}

}

login_view.php - ビュー

<div class="container">
  <form class="form-signin" action="<?php echo base_url('login/process');?>" method="post" id="loginForm">
    <h2 class="form-signin-heading"><img src="<?php echo base_url('assets/img/hms_icon.png'); ?>" />User Login</h2>
    <input type="text" class="input-block-level" placeholder="Username" name="username" id="username">
    <input type="password" class="input-block-level" placeholder="Password" name="password" id="password">
    <button class="btn btn-large btn-primary" type="submit" name="login" id="login">Sign in</button> 

    <div id="report"></div>
  </form>
 </div> <!-- /container -->

login_model.php - モデル

  <?php
 Class Login_model extends CI_Model
{

function __construct(){
    parent::__construct();
}

public function validate(){
    // grab user input
    $username = $this->security->xss_clean($this->input->post('username'));
    $password = $this->security->xss_clean($this->input->post('password'));

    // Prep the query
    $this->db->where('username', $username);
    $this->db->where('password', $password);

    // Run the query
    $query = $this->db->get('users');
    // Let's check if there are any results
    if($query->num_rows == 1)
    {
        // If there is a user, then create session data
        $row = $query->row();
        $data = array(
                '_id' => $row->userid,
                'username' => $row->username,
                'validated' => true
                );
        $this->session->set_userdata($data);
        return true;
    }
    // If the previous process did not validate
    // then return false.
    return false;
 }
 }
?>

エラーが発生します

 <?php echo base_url('login/process');?>

オブジェクトが見つかりません。ここで何が欠けていますか?どんな助けでも大歓迎です。

4

3 に答える 3