用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1386|回复: 0
收起左侧

加载model后显示空页面

[复制链接]
发表于 2014-3-3 08:10:47 | 显示全部楼层 |阅读模式
本帖最后由 polandeme 于 2014-3-3 08:26 编辑

只要在C里面加载model后页面就会什么都不显示,注释掉那句就会显示
Controll
PHP复制代码
<?php class User extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this ->load ->helper('url');
        $this ->load ->model('m_user');  // 加载这句后就会什么都不显示
    }
    public function index() {
        // to do
        // 判断是否登录
        // if 登录 进入个人中心
        // else 进入登录页面
    }
    public function register() {
        $this ->load ->view('template/header');
        $this ->load ->view('register');
    }
    public function add_user() {
        $this ->load ->library('form_validation');
        $this ->form_validation ->set_rules('userName','UserName','required');
        $this ->form_validation ->set_rules('userEmail','UserEmail','required');
        $this ->form_validation ->set_rules('userPwd','UserPassward','required');
        if($this ->form_validation ->run() == False ) {
            $this ->register();
        } else {
            $this ->m_user ->add_user();
            $this ->register();
        }
    }
}
?>
复制代码



model
PHP复制代码
<?php class M_user extends CI__Model {
    public function __construct() {
        parent::__construct();
    }
 
    public function add_user() {
        /*$userName = $this ->input ->post('userName');
        $userEmail = $this ->input ->post('userEmail');
        $userPwd = $this ->input ->post('userPwd');
        $userIp = $this ->input ->ip_address();
        $sql = "INSERT INTO sh_user (u_name, u_email, u_passward, u_reg_ip, u_reg_time )
                VALUES ('".$userName."', '".$userEmail."', '".$userPwd."', '".$userIp."', now())";
        $res = mysql_query($sql) or die("error". mysql_error);*/

 
        $data = array(
            // 'u_name' => $this ->input ->post('userName'),
            'u_email' => $this ->input ->post('userEmail'),
            'u_passward' => $this ->input ->post('userPwd')
            'u_reg_ip' => $this ->input ->ip_address()
            // 'u_reg_time' => now();
        );
        $this ->db ->insert('sh_user', $data);
    }
}
?>
复制代码




本版积分规则