<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
		//$memnum=I('mem_number');
		//$password=I('mem_password');
	 if(IS_POST){
	     	$mems=D('members');
		   if($mems->create()){
			    if($mems->login()){
					$this->redirect('Index/index');
					session('name');
					session('card');
					}else{
				  $this->show_msg('用户名或者密码有误','index');
				   // $this->error('用户名或者密码有误');		
						}
			   }else{
				   $this->error($mems->getError());
				   }
			 return;
		 }


        $this->display();
    }
	
	
	
	 //封装的消息提示方法，控制器调用此方法 
	  public function show_msg($msg="", $url=""){
             @header("Content-Type:text/html;charset=utf-8");
              echo '<script type="text/javascript">';
              echo 'alert("'.$msg.'");';
              if(!empty($url)){
              echo 'location.href = "'.$url.'"';
                              }else{
                                    echo 'history.go(-1);';
                                   }
              echo '</script>';
              exit;
}



	
	

}


