[英]Codeigniter ERROR LOADING PAGE
enter image description here 在此处输入图片说明
Im tryng to develop a login system in Codeigniter but for some reason, when the form is submited and ERROR LOADING PAGE is displayed. 我试图在Codeigniter中开发一个登录系统,但是由于某种原因,当提交表单并显示ERROR LOADING PAGE时。 I tried to reach out many possibilities on the action="" in the form but it always gives me the same error.
我试图在表单中的action =“”上找到很多可能性,但是它总是给我同样的错误。 Can someone help me with that?
有人可以帮我吗?
There follows my code: 以下是我的代码:
My View signIn.php 我的视图signIn.php
<?php include("includes/header.php"); ?>
<body>
<div id="login" data-role="page" class="outpage">
<div data-role="header"><h1>login</h1></div>
<div class="confpage" style="text-align:center;">
<img src="<?php echo base_url() ?>template/images/logomarca.jpg" />
<form action="user/login" method="post">
<input type="text" placeholder="Email" name="email" id="email">
<input type="password" placeholder="Password" name="password" id="password">
<button class="buttonDefault" type="submit" name="submit" id="submit">Login</button>
</form>
<a data-transition="slide" href="<?php echo base_url(); ?>">Back</a>
</div>
</div>
</body>
My controller user.php 我的控制器user.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class User extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->model('user_model');
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
}
public function signIn(){
$this->load->view('signIn');
}
public function login(){
$this->form_validation->set_rules('email', 'Email', 'trim|required');
$this->form_validation->set_rules('password', 'Password', 'trim|required|callback_check_database');
if($this->form_validation->run() == FALSE){
$this->load->view('signUp');
}else{
$this->load->view('admin/admin');
}
}
function check_database($password){
//Field validation succeeded. Validate against database
$email = $this->input->post('email');
//query the database
$result = $this->user->login($email, $password);
if($result) {
$sess_array = array();
foreach($result as $row){
$_SESSION['id'] = $row->id;
$_SESSION['fname'] = $row->fname;
$sess_array = array(
'id' => $row->id,
'fname' => $row->fname);
$this->session->set_userdata('logged_in', $sess_array);
}
return TRUE;
}
else
{
$this->form_validation->set_message('check_database', 'Invalid email or password');
return false;
}
}
}
And thats my model user_model.php 那就是我的模型user_model.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class User_model extends CI_Model{
public function __contruct(){
parent::__contruct();
}
public function signUp($data){
$this->db->insert('users', $data);
}
public function login($email, $password) {
$password = md5($password);
$this -> db -> select('id, fname, lname, password');
$this -> db -> from('users');
$this -> db -> where('email', $email);
$this -> db -> where('password', $password);
$this -> db -> limit(1);
$query = $this -> db -> get();
if($query -> num_rows() == 1) {
return $query->result();
}else {
return false;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.