polandeme 发表于 2014-3-3 08:10:47

加载model后显示空页面

本帖最后由 polandeme 于 2014-3-3 08:26 编辑

只要在C里面加载model后页面就会什么都不显示,注释掉那句就会显示
Controll
<?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 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);
    }
}
?>



页: [1]
查看完整版本: 加载model后显示空页面