|
本帖最后由 追影 于 2011-8-9 09:58 编辑
各位老兄,现在我出现了这个问题;
1、我建立了一个member_mode模型,用户登录验证(member_login)时模型载入正常,函数调用也正常
2、用户注册(member_reg)时,没有提示错误信息,模型不载入,函数不调用。同时,只显示“输出测试1”,无法显示“输出测试2”、“输出测试3”;
3、请高手予以解惑,万分感谢!!!
不知道是怎么回事儿,新手!!!
以下是代码:
这是site.php文件 控制器:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->data['title'] = "开发测试";
}
public function index()
{
$this->load->view('site_index' , $this->data );
}
public function register()
{
$this->load->view('site_index_register' , $this->data );
}
public function serch()
{
$this->load->view('site_index_serch' , $this->data );
}
public function error()
{
show_404();
}
public function member_login()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username' , '用户账户' , 'trim|required|xss_clean' );
$this->form_validation->set_rules('password' , '用户密码' , 'trim|required|xss_clean|md5' );
if ($this->form_validation->run())
{
$username = $this->input->post('username');
$password = substr($this->input->post('password'), 1 , -1);
$this->load->model('member_model' , 'member');
$login_data = $this->member->member_login($username, $password);
if ($login_data)
{
$member_login_session_data = array(
'user_id' => $login_data->u_id,
'user_type' => $login_data->u_type,
'user_name' => $login_data->u_name,
'login_successful' => True,
);
$this->session->set_userdata($member_login_session_data);
}
else
{
redirect('site');
}
}
else
{
redirect('site/error');
}
}
public function reg_active()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username' , '用户账户' , 'trim|required|xss_clean' );
$this->form_validation->set_rules('password' , '用户密码' , 'trim|required|xss_clean|md5' );
if ($this->form_validation->run())
{
$username = $this->input->post('username');
$password = substr($this->input->post('password'), 1 , -1);
echo "输出测试1";
$this->load->model('member_model' , 'member');
echo "输出测试2";
$this->member->member_reg();
echo "输出测试3";
}
else
{
echo "flase";
}
}
}
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
这是member_mode.php文件
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Member_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
public function member_login($username , $password)
{
$this->db->where('u_name', $username);
$this->db->where('u_pawd', $password);
$this->db->limit(1);
$login_result = $this->db->get('member');
if($login_result->num_rows() == 1)
{
$result = $login_result->row();
return $result;
}
else
return FALSE;
}
public function member_reg()
{
echo "asdasd";
$regdata = array(
'test' => 'test'
)
$this->db->insert('test', $regdata);
}
}
|
|