function register()
 {
     //        $user = D('User');
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         if (!$user->create()) {
             //验证失败,输出错误信息
             //                dump($user->getError());
             //                exit;
             $this->assign('error', $user->getError());
         } else {
             //把爱好由数组转变为字符串'1,2,3'的形式
             //使用ARf方式处理爱好的字段信息
             //create()方法收集的数据也是把数据变为模型对象的属性
             $user->user_hobby = implode(',', $_POST['user_hobby']);
             $rst = $user->add();
             if ($rst) {
                 $this->success('注册成功,正在跳转!', U('Index/index'), 3);
             } else {
                 echo 'error';
             }
         }
     } else {
         $this->display();
     }
 }
 function upd($UserId)
 {
     $user = new \Model\UserModel();
     //两个逻辑:展示表单、收集表单
     if (!empty($_POST)) {
         $z = $user->create();
         //收集post表单数据	creat()会进行表单验证
         if (!$z) {
             //验证失败,输出错误信息
             show_bug($user->getError());
             $this->error('修改失败');
         } else {
             //验证成功,添加到数据库`
             $rst = $user->where("UserId='{$UserId}'")->save();
             if ($rst) {
                 $this->success('修改成功', U('User/manage'));
             } else {
                 $this->error('修改失败', U('User/manage'));
             }
         }
     } else {
         $info = $user->where("UserId='{$UserId}'")->find();
         //一维数组
         $this->assign('info', $info);
         $this->display();
     }
 }
예제 #3
0
 public function active()
 {
     $key = $_GET['key'];
     $email = $_GET['email'];
     $model = new \Model\UserModel();
     $info = $model->where("email='{$email}'")->find();
     if (!$info) {
         //匹配不到用户
         $this->error('激活失败', U('login'), 2);
     }
     if ($key != $info['validate']) {
         $this->error('激活失败', U('login'), 2);
     }
     //如果已经激活,则不用再激活
     if ($info['active'] == 1) {
         $this->success('已完成激活,无需再次激活', U('login'), 1);
         exit;
     }
     //开始激活setField(修改字段)
     $rs = $model->where("email='{$email}'")->setField('active', 1);
     if ($rs) {
         //激活成功,提示跳转
         $this->success('激活成功,体验非一般的感觉吧', U('login'), 1);
         exit;
     }
     $this->error('激活失败,请重新激活', U('login'), 2);
 }
예제 #4
0
 function register(){
     $user = new \Model\UserModel();
     //判断表单是否提交
     if(!empty($_POST)){
         //只有全部验证通过$z才会为真
         if(!$user -> create()){
             //验证失败,输出错误信息
             //getError()方法返回验证失败的信息
             show_bug($user->getError());
         } else {
             //把爱好由数组变为字符串"1,3,4"
             //使用AR方式处理爱好的字段信息
             //create()方法收集的数据也是把数据变为模型对象的属性
             $user -> user_hobby = implode(',',$_POST['user_hobby']);
             $rst = $user -> add();
             if($rst){
                 $this -> success('注册成功',U('Index/index'));
             } else {
                 $this -> error('注册失败',U('Index/index'));
             }
         }
     } else {
         $this -> display();
     }
 }
예제 #5
0
 function register()
 {
     //$user=new \Model\UserModel();
     show_bug($_POST);
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         //print_r($_POST);
         $data = $user->create();
         //集成表单验证
         if (!$data) {
             show_bug($user->getError());
         } else {
             //添加数据
             $user->user_hobby = implode(',', $_POST['user_hobby']);
             $charu = $user->add();
             if ($charu) {
                 $this->success('注册成功', U('Index/index'));
             } else {
                 $this->error('注册失败', U('Index/index'));
             }
         }
     } else {
         $this->display();
     }
 }
예제 #6
0
 public function showlist()
 {
     //
     $user = new \Model\UserModel();
     $info = $user->select();
     $this->assign('info', $info);
     $this->display();
 }
예제 #7
0
 public function login()
 {
     //如果登录跳回来源页
     if (!empty($_SESSION['user_info'])) {
         header("Location:" . $_COOKIE['url']);
     } else {
         $model = new \Model\UserModel();
         if ($_COOKIE['url'] == '/index.php/Home/user/login.html' || $_COOKIE['url'] == '/index.php/Home/user/null') {
             setcookie('url', '/', time() + 1800, '/');
         }
         //如果有post值判断为ajax,如果没展示界面
         if (empty($_POST)) {
             //                //随机AB方案
             $this->assign(head, rand(1, 4));
             //                $this->assign(zjj_xm,$zjj_xm);
             $user_agent = $_SERVER['HTTP_USER_AGENT'];
             if (strpos($user_agent, 'MicroMessenger') === false) {
                 // 非微信浏览器禁止浏览
                 $is_wx = '0';
             } else {
                 $is_wx = '1';
             }
             $this->assign('is_wx', $is_wx);
             //公共目录下模型
             //                $model = new \Model\UserModel();
             $isLogin = $model->IsLogin('liyulin', '17951123');
             echo $isLogin['user_name'];
             //home目录下模型 namespace Home\Model
             //                echo D('User')->IsLogin();
             $this->display('login');
         } else {
             $user = $_POST['Account'];
             $pass = $_POST['Password'];
             //判断用户是否存在
             $isUser = $model->IsLogin($user, $pass, 1);
             //                $isUser = D('User')->IsLogin($user,$pass, 3);
             //判读密码是否正确\
             //使用手机号码,邮箱,用户名都能登录
             //                $userInfo = D('User')->IsLogin($user, $pass, 1);
             $userInfo = $model->IsLogin($user, $pass, 1);
             if (empty($isUser)) {
                 $jsonArr = array('status' => false, 'message' => '11您输入的用户名不存在,user' . $isUser['user_name'] . " and pass:"******" end");
             } elseif (empty($userInfo)) {
                 $jsonArr = array('status' => false, 'message' => '22您输入的密码错误');
                 //登录成功页面跳转回来源页面
             } elseif (!empty($userInfo)) {
                 session_start();
                 $_SESSION['user_info'] = $userInfo;
                 $jsonArr = array('status' => true, 'message' => $_COOKIE['url']);
             }
             echo json_encode($jsonArr);
             //                $this->display('index');
         }
     }
 }
예제 #8
0
 function checkNm($name)
 {
     //通过Model 查询$name是否存在
     $user = new \Model\UserModel();
     $z = $user->where("username='******'")->find();
     if ($z == null) {
         echo "<span style='color:yellow;font-size:14px'>用户名合法</span>";
     } else {
         echo "<span style='color:red;font-size:14px'>已被注册</span>";
     }
     exit;
 }
예제 #9
0
 public function register()
 {
     $obj = new \Model\UserModel();
     if (!empty($_POST)) {
         $rand = rand(0, 9999);
         $url = substr(md5(time() - $rand), 12, 8);
         $_POST['url'] = $url;
         $_POST['time'] = time();
         $_POST['lovetime'] = $_POST['ltime'] ? strtotime($_POST['ltime']) : null;
         while (empty($_POST['content'])) {
             $content = M('poem');
             $poem = $content->query('select poem from poem where id=(select FLOOR(1 + (RAND() * (SELECT MAX(id) FROM `poem`)))) limit 1');
             $_POST['content'] = $poem['0']['poem'];
         }
         $z = $obj->create();
         if ($z) {
             $result = $obj->add();
             if ($result) {
                 echo '<script>alert("页面生成成功")</script>';
                 echo '<script>alert("记得记下网址链接哦,快快发给朋友们Show一下吧!")</script>';
                 echo '<script language="javascript" type="text/javascript">window.location.href="' . U('Home/Index/Index/id/' . $url) . '";</script>';
             } else {
                 echo '<script>alert("生成失败,请重新提交或联系")</script>';
                 echo '<script language="javascript" type="text/javascript">window.location.href="' . U('Home/Index/register') . '";</script>';
             }
         } else {
             $err = $obj->getError();
             echo '<script>alert("';
             foreach ($err as $key) {
                 echo $key . '\\n';
             }
             echo '")</script>';
             echo '<script language="javascript" type="text/javascript">history.go(-1);</script>';
             exit;
         }
     }
     if ($this->isMobile()) {
         $this->display('m_register');
     } else {
         $this->display();
     }
 }
 function register()
 {
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         //收集post表单数据	creat()会进行表单验证
         if (!$user->create()) {
             //验证失败,输出错误信息
             show_bug($user->getError());
             //返回添加页面
             $this->error('注册失败', 'javascript:history.back(-1)');
         } else {
             $rst = $user->add();
             if ($rst) {
                 $this->success('注册成功', U('Login/login'));
             } else {
                 $this->error('注册失败', U('Login/login'));
             }
         }
     } else {
         $this->display();
     }
 }
예제 #11
0
    function register(){
        $user = new \Model\UserModel();
        //判断表单是否提交
        if(!empty($_POST)){
            print_r($_POST);
            $z = $user -> create();  //集成表单验证
            //只有全部验证通过$z才会为真
            if(!$z){
                //验证失败,输出错误信息
                //getError()方法返回验证失败的信息
                show_bug($user->getError());

            }
//            $rst = $user -> add();
//            if($rst){
//                echo "success";
//            } else {
//                echo "error";
//            }
        } else {
        }
        $this -> display();
    }
 function upd($UserId)
 {
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         //收集post表单数据	creat()会进行表单验证
         if (!$user->create()) {
             //验证失败,输出错误信息
             show_bug($user->getError());
             $this->error('修改失败', 'javascript:history.back(-1)');
         } else {
             $rst = $user->where("UserId='{$UserId}'")->save();
             if ($rst) {
                 $this->success('修改成功', U('Information/show'));
             } else {
                 $this->error('修改失败', 'javascript:history.back(-1)');
             }
         }
     } else {
         $info = $user->where("UserId='{$UserId}'")->find();
         //一维数组
         $this->assign('info', $info);
         $this->display();
     }
 }
예제 #13
0
 /**
  * [chkname description] 检验用户名字是否注册的接口
  * @Author   alanfang2012@163.com
  * @DateTime 2015-09-01T15:43:39+0800
  * @param    string  $user_name
  * @return   json      
  */
 public function chknameAPI()
 {
     $user_name = $_GET['user_name'];
     $user_mod = new \Model\UserModel();
     $info = $user_mod->chkName($user_name);
     if ($info) {
         die(json_encode(array('status' => "error")));
     }
     die(json_encode(array('status' => "OK")));
 }
 function login()
 {
     if (!empty($_POST)) {
         //验证码校验
         $verify = new \Think\Verify();
         if (!$verify->check($_POST['captcha'])) {
             echo "验证码错误";
         } else {
             //验证码正确
             //身份验证
             if (2 == $_POST['status']) {
                 //管理员身份登录
                 //用户名密码校验,在model模型里写一个方法进行验证
                 $admin = new \Model\AdminsModel();
                 $rst = $admin->checkNamePwd($_POST['adminName'], $_POST['adminPwd']);
                 if ($rst === false) {
                     echo "用户名或密码错误";
                 } else {
                     //登录信息持久化SESSION
                     session('adminName', $rst['user_name']);
                     session('Password', $rst['Password']);
                     session('TrueName', $rst['TrueName']);
                     session('login', '1');
                     session('status', 'admin');
                     //页面跳转到会后台录首页redirect()
                     $this->redirect("Admin/Index/index");
                 }
             } else {
                 //会员身份登录
                 $user = new \Model\UserModel();
                 //验证用户是否注册
                 $islogin = $user->checkLogin($_POST['adminName']);
                 if ($islogin === false) {
                     echo "用户名不存在,请注册后再登陆";
                 } else {
                     //用户名存在
                     //验证用户是否注册成功
                     $info = $user->checkLabel($_POST['adminName']);
                     if ($info === false) {
                         echo "用户注册正在通过审查,请等待";
                     } else {
                         //注册通过审查
                         //用户名密码校验,在model模型里写一个方法进行验证
                         $rst = $user->checkNamePwd($_POST['adminName'], $_POST['adminPwd']);
                         if ($rst === false) {
                             echo "用户名或密码错误";
                         } else {
                             //用户名和密码正确则登陆成功
                             //登录信息持久化SESSION
                             session('adminName', $rst['UserName']);
                             session('Password', $rst['Password']);
                             session('login', '1');
                             session('status', 'user');
                             //页面跳转到后台首页redirect()
                             $this->redirect("Home/Index/index");
                         }
                     }
                 }
             }
         }
     }
     $this->display();
 }