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();
     }
 }
 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();
     }
 }
예제 #3
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();
     }
 }
예제 #4
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();
     }
 }
예제 #5
0
 public function login()
 {
     //实现登陆
     if (IS_POST) {
         $model = new \Model\UserModel();
         if ($model->login()) {
             $url = empty($_SESSION['return_url']) ? 'Index/index' : $_SESSION['return_url'];
             //用户登陆成功调用转移cookie中购物车的数据入数据库
             $cart_model = new \Model\CartModel();
             $cart_model->cookie2db();
             $this->success('登陆成功', U($url), 1);
             exit;
         }
         $this->error($model->getError());
     }
     $this->display();
 }
예제 #6
0
 public function register()
 {
     //展示表单,收集数据
     $user = new \Model\UserModel();
     if (!empty($_POST)) {
         $arr = $user->create();
         if ($arr) {
             $z = $user->add($arr);
             if ($z) {
                 $this->redirect('User/login');
             }
         }
         $this->assign('errorinfo', $user->getError());
         //获取验证错误信息
     }
     $this->display();
 }
예제 #7
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();
     }
 }
예제 #8
0
 /**
  * [signup description] 前台用户注册
  * @Author   alanfang2012@163.com
  * @DateTime 2015-09-01T22:27:15+0800
  */
 public function signup()
 {
     if (!empty($_POST)) {
         $user_mod = new \Model\UserModel();
         $res = $user_mod->create();
         if ($res) {
             $p = $user_mod->makePwd($res['user_name'], $res['user_pswd']);
             $res['user_pswd'] = $p['user_pswd'];
             $res['salt'] = $p['salt'];
             $z = $user_mod->add($res);
             session('user_id', $z);
             session('user_name', $res['user_name']);
             if ($z) {
                 $this->redirect('user/info');
             }
         }
         $this->assign('errorInfo', $user_mod->getError());
     }
     $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();
     }
 }
예제 #10
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();
     }
 }